{"id":25902319,"url":"https://github.com/dapplets/web-guide-contract","last_synced_at":"2025-10-25T03:14:05.756Z","repository":{"id":233076526,"uuid":"772449053","full_name":"dapplets/web-guide-contract","owner":"dapplets","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-15T08:04:42.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-03T03:15:50.156Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dapplets.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-15T08:04:07.000Z","updated_at":"2024-03-15T08:04:46.000Z","dependencies_parsed_at":"2024-04-13T13:22:53.637Z","dependency_job_id":"a78a7f5f-c1e0-4669-83e8-290216f00112","html_url":"https://github.com/dapplets/web-guide-contract","commit_stats":null,"previous_names":["dapplets/web-guide-contract"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dapplets/web-guide-contract","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapplets%2Fweb-guide-contract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapplets%2Fweb-guide-contract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapplets%2Fweb-guide-contract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapplets%2Fweb-guide-contract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dapplets","download_url":"https://codeload.github.com/dapplets/web-guide-contract/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapplets%2Fweb-guide-contract/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262626645,"owners_count":23339406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-03T03:15:52.417Z","updated_at":"2025-10-25T03:14:05.709Z","avatar_url":"https://github.com/dapplets.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hello NEAR Contract\n\nThe smart contract exposes two methods to enable storing and retrieving a greeting in the NEAR network.\n\n```rust\nconst DEFAULT_GREETING: \u0026str = \"Hello\";\n\n#[near_bindgen]\n#[derive(BorshDeserialize, BorshSerialize)]\npub struct Contract {\n    greeting: String,\n}\n\nimpl Default for Contract {\n    fn default() -\u003e Self {\n        Self { greeting: DEFAULT_GREETING.to_string() }\n    }\n}\n\n#[near_bindgen]\nimpl Contract {\n    // Public: Returns the stored greeting, defaulting to 'Hello'\n    pub fn get_greeting(\u0026self) -\u003e String {\n        return self.greeting.clone();\n    }\n\n    // Public: Takes a greeting, such as 'howdy', and records it\n    pub fn set_greeting(\u0026mut self, greeting: String) {\n        // Record a log permanently to the blockchain!\n        log!(\"Saving greeting {}\", greeting);\n        self.greeting = greeting;\n    }\n}\n```\n\n\u003cbr /\u003e\n\n# Quickstart\n\n1. Make sure you have installed [rust](https://rust.org/).\n2. Install the [`NEAR CLI`](https://github.com/near/near-cli#setup)\n\n\u003cbr /\u003e\n\n## 1. Build, Test and Deploy\nTo build the contract you can execute the `./build.sh` script, which will in turn run:\n\n```bash\nrustup target add wasm32-unknown-unknown\ncargo build --target wasm32-unknown-unknown --release\n```\n\nThen, run the `./deploy.sh` script, which will in turn run:\n\n```bash\nnear dev-deploy --wasmFile ./target/wasm32-unknown-unknown/release/hello_near.wasm\n```\n\nthe command [`near dev-deploy`](https://docs.near.org/tools/near-cli#near-dev-deploy) automatically creates an account in the NEAR testnet, and deploys the compiled contract on it.\n\nOnce finished, check the `./neardev/dev-account` file to find the address in which the contract was deployed:\n\n```bash\ncat ./neardev/dev-account\n# e.g. dev-1659899566943-21539992274727\n```\n\n\u003cbr /\u003e\n\n## 2. Retrieve the Greeting\n\n`get_greeting` is a read-only method (aka `view` method).\n\n`View` methods can be called for **free** by anyone, even people **without a NEAR account**!\n\n```bash\n# Use near-cli to get the greeting\nnear view \u003cdev-account\u003e get_greeting\n```\n\n\u003cbr /\u003e\n\n## 3. Store a New Greeting\n`set_greeting` changes the contract's state, for which it is a `change` method.\n\n`Change` methods can only be invoked using a NEAR account, since the account needs to pay GAS for the transaction. In this case, we are asking the account we created in step 1 to sign the transaction.\n\n```bash\n# Use near-cli to set a new greeting\nnear call \u003cdev-account\u003e set_greeting '{\"greeting\":\"howdy\"}' --accountId \u003cdev-account\u003e\n```\n\n**Tip:** If you would like to call `set_greeting` using your own account, first login into NEAR using:\n\n```bash\n# Use near-cli to login your NEAR account\nnear login\n```\n\nand then use the logged account to sign the transaction: `--accountId \u003cyour-account\u003e`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdapplets%2Fweb-guide-contract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdapplets%2Fweb-guide-contract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdapplets%2Fweb-guide-contract/lists"}