From ba41d9572dbff0d27c5a3e30b7ca3129a60fd7e6 Mon Sep 17 00:00:00 2001 From: ghimire007 <69514062+ghimire007@users.noreply.github.com> Date: Tue, 5 Sep 2023 09:38:50 +1000 Subject: [PATCH] Update upgrade.md --- docs/2.develop/upgrade.md | 45 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/docs/2.develop/upgrade.md b/docs/2.develop/upgrade.md index 59255c44dd8..b17a37480d2 100644 --- a/docs/2.develop/upgrade.md +++ b/docs/2.develop/upgrade.md @@ -20,6 +20,10 @@ Contract's can be updated in two ways: ## Updating Through Tools Simply re-deploy another contract using your preferred tool, for example, using [NEAR CLI](../4.tools/cli.md): + + + + ```bash # If you already used dev-deploy the same account will be used near dev-deploy --wasmFile @@ -28,6 +32,28 @@ near dev-deploy --wasmFile near deploy --wasmFile ``` + + + + + + +```bash +# If you already used dev-deploy the same account will be used +near contract deploy .testnet use-file without-init-call network-config testnet sign-with-keychain + + +# If you logged in +near contract deploy use-file without-init-call network-config testnet sign-with-keychain send + +``` + + + + + + + --- ## Programmatic Update @@ -45,7 +71,7 @@ A smart contract can also update itself by implementing a method that: #### How to Invoke Such Method? - + ```bash # Load the contract's raw bytes @@ -56,7 +82,20 @@ near call update_contract "$CONTRACT_BYTES" --base64 --accoun ``` - + + + +```bash +# Load the contract's raw bytes +CONTRACT_BYTES=`cat ./path/to/wasm.wasm | base64` + +# Call the update_contract method +near contract call-function as-transaction update_contract base64-args "$CONTRACT_BYTES" prepaid-gas '300 TeraGas' attached-deposit '0 NEAR' sign-as network-config testnet sign-with-keychain send + +``` + + + ```js // Load the contract's raw bytes @@ -151,4 +190,4 @@ Notice that `migrate` is actually an [initialization method](./contracts/anatomy :::tip You can follow a migration step by step in the [official migration example](https://github.com/near-examples/update-migrate-rust/tree/main/contracts/basic-updates/base) -::: \ No newline at end of file +:::