diff --git a/docs/sdk/rust/building/prototyping.md b/docs/sdk/rust/building/prototyping.md index 1a874358f65..1cc42422d21 100644 --- a/docs/sdk/rust/building/prototyping.md +++ b/docs/sdk/rust/building/prototyping.md @@ -4,6 +4,8 @@ sidebar_label: Rapid Prototyping title: "Upgrading Contracts: Rapid Prototyping" --- import {CodeTabs, Language, Github} from "@site/components/codetabs"; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; # Rapid Prototyping @@ -42,11 +44,24 @@ The [rust-status-message](https://github.com/near-examples/rust-status-message) Let's say you deploy this contract to testnet, then call it with: + + + ```bash near call [contract] set_status '{"message": "lol"}' --accountId you.testnet near view [contract] get_status '{"account_id": "you.testnet"}' ``` + + + +```bash +near contract call-function as-transaction [contract] set_status json-args '{"message": "lol"}' prepaid-gas '30 TeraGas' attached-deposit '0 NEAR' sign-as you.testnet network-config testnet sign-with-keychain send + +near contract call-function as-read-only [contract] get_status text-args '{"account_id": "you.testnet"}' network-config testnet now +``` + + This will return the message that you set with the call to `set_status`, in this case `"lol"`. At this point the contract is deployed and has some state. @@ -97,10 +112,26 @@ You build & deploy the contract again, thinking that maybe because the new `tagl ### 1. `rm -rf neardev && near dev-deploy` When first getting started with a new project, the fastest way to deploy a contract is [`dev-deploy`](/concepts/basics/accounts/creating-accounts): + + ```bash near dev-deploy [--wasmFile ./path/to/compiled.wasm] ``` + + + +```bash +near account create-account sponsor-by-faucet-service .testnet autogenerate-new-keypair save-to-keychain network-config testnet create + +near contract deploy .testnet use-file without-init-call network-config testnet sign-with-keychain + +``` + + + + + This does a few things: @@ -119,21 +150,58 @@ The easiest way is just to delete the `neardev` folder, then run `near dev-deplo If you want to have a predictable account name rather than an ever-changing `dev-*` account, the best way is probably to create a sub-account: + + + ```bash title="Create sub-account" near create-account app-name.you.testnet --masterAccount you.testnet ``` + + + +```bash title="Create sub-account" +near account create-account fund-myself app-name.you.testnet '100 NEAR' autogenerate-new-keypair save-to-keychain sign-as you.testnet network-config testnet sign-with-keychain send +``` + + + Then deploy your contract to it: + + + ```bash title="Deploy to sub-account" near deploy --accountId app-name.you.testnet [--wasmFile ./path/to/compiled.wasm] ``` + + + +```bash title="Deploy to sub-account" +near contract deploy app-name.you.testnet use-file <./path/to/compiled.wasm> without-init-call network-config testnet sign-with-keychain send +``` + + + + In this case, how do you delete all contract state and start again? Delete the sub-account and recreate it. + + + + ```bash title="Delete sub-account" near delete app-name.you.testnet you.testnet ``` + + + +```bash title="Delete sub-account" +near account delete-account app-name.you.testnet beneficiary you.testnet network-config testnet sign-with-keychain send +``` + + This sends all funds still on the `app-name.you.testnet` account to `you.testnet` and deletes the contract that had been deployed to it, including all contract state.