Skip to content

Commit

Permalink
Merge pull request #3 from ghimire007/patch-3
Browse files Browse the repository at this point in the history
Update upgrade.md
  • Loading branch information
ghimire007 authored Sep 4, 2023
2 parents 09217c0 + ba41d95 commit 33d1b0b
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions docs/2.develop/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):


<Tabs className="language-tabs" groupId="code-tabs">
<TabItem value="Near-CLI">

```bash
# If you already used dev-deploy the same account will be used
near dev-deploy --wasmFile <new-contract>
Expand All @@ -28,6 +32,28 @@ near dev-deploy --wasmFile <new-contract>
near deploy <account-id> --wasmFile <new-contract>
```



</TabItem>
<TabItem value="Near-CLI-rs">


```bash
# If you already used dev-deploy the same account will be used
near contract deploy <my-new-dev-account>.testnet use-file <route_to_wasm> without-init-call network-config testnet sign-with-keychain


# If you logged in
near contract deploy <accountId> use-file <route_to_wasm> without-init-call network-config testnet sign-with-keychain send

```


</TabItem>
</Tabs>



---

## Programmatic Update
Expand All @@ -45,7 +71,7 @@ A smart contract can also update itself by implementing a method that:

#### How to Invoke Such Method?
<Tabs className="language-tabs" groupId="code-tabs">
<TabItem value="Terminal">
<TabItem value="Near-CLI">

```bash
# Load the contract's raw bytes
Expand All @@ -56,7 +82,20 @@ near call <contract-account> update_contract "$CONTRACT_BYTES" --base64 --accoun
```

</TabItem>
<TabItem value="🌐 JavaScript">

<TabItem value="Near-CLI-rs">

```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 <contract-account> update_contract base64-args "$CONTRACT_BYTES" prepaid-gas '300 TeraGas' attached-deposit '0 NEAR' sign-as <manager-account> network-config testnet sign-with-keychain send

```

</TabItem>
<TabItem value="🌐 JavaScript">

```js
// Load the contract's raw bytes
Expand Down Expand Up @@ -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)
:::
:::

0 comments on commit 33d1b0b

Please sign in to comment.