You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/smart-contracts/global-contracts.md
+17-1Lines changed: 17 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,23 @@ import TabItem from '@theme/TabItem';
8
8
9
9
Global contracts allow smart contracts to be deployed once and reused by any account without incurring high storage costs.
10
10
11
-
---
11
+
## Overview
12
+
13
+
If you've ever deployed the same contract code to multiple accounts, you’ve likely noticed that each deployment requires you to pay the full storage cost again — since the size of the WASM file determines how much `NEAR` is locked on the account.
14
+
15
+
Global Contracts solve this inefficiency by allowing the same contract code to be shared across multiple accounts, so storage cost is paid only once.
16
+
17
+
There are two ways to reference a global contract:
18
+
-[By Account](#reference-by-account)
19
+
-[By Hash](#reference-by-hash)
20
+
21
+
### Reference by Account
22
+
23
+
When using a reference **by account**, the contract code is tied to another account. If that account later deploys a new version of the contract, your account will automatically start using the updated code, with no need for redeployment.
24
+
25
+
### Reference by Hash
26
+
27
+
When using a reference **by hash**, you reference the global contract by its immutable code hash. This ensures you're always using the exact same version, and it will never change unless you explicitly redeploy with a different hash.
@@ -764,7 +764,7 @@ Accounts can transfer different types of tokens to other accounts, including the
764
764
<Tabs groupId="api">
765
765
<TabItem value="js" label="🌐 JavaScript">
766
766
767
-
To begin with, you’ll need the `@near-js/tokens`package, which provides the necessary utilities.
767
+
To begin with, you’ll need the `@near-js/tokens`package, which provides the necessary utilities.
768
768
769
769
Once you've [created an `Account` instance](#instantiate-account), you can transfer tokens to others. Let’s start by looking at how to transfer native `NEAR` tokens.
770
770
@@ -874,7 +874,7 @@ A smart contract exposes its methods, and making a function call that modifies s
874
874
<Tabs groupId="api">
875
875
<TabItem value="js" label="🌐 JavaScript">
876
876
877
-
Once you've [created an `Account` instance](#instantiate-account), you can start interacting with smart contracts.
877
+
Once you've [created an `Account` instance](#instantiate-account), you can start interacting with smart contracts.
878
878
879
879
For example, let’s say there’s a [Guestbook](/tutorials/examples/guest-book#testing-the-contract) contract deployed at `guestbook.near-examples.testnet`, and you want to add a message to it. To do that, you’d call its `add_message` method.
880
880
@@ -1164,13 +1164,11 @@ Unlike many other blockchains, contracts on NEAR are mutable, meaning you have t
1164
1164
1165
1165
### Deploy a Global Contract {#deploy-a-global-contract}
1166
1166
1167
-
If you've ever deployed the same contract code to multiple accounts, you’ve likely noticed that each deployment requires you to pay the full storage cost again — since the size of the WASM file determines how much `NEAR` is locked on the account.
1168
-
1169
-
Global Contracts solve this inefficiency by allowing the same contract code to be shared across multiple accounts, so storage cost is paid only once.
1167
+
[Global contracts](../smart-contracts/global-contracts.md) allow smart contracts to be deployed once and reused by any account without incurring high storage costs.
1170
1168
1171
1169
There are two ways to reference a global contract:
1172
-
- **By account:** The contract code is tied to another account. If that account later deploys a new version of the contract, your account will automatically start using the updated code, with no need for redeployment.
1173
-
- **By hash:** You reference the contract by its immutable code hash. This ensures you're always using the exact same version, and it will never change unless you explicitly redeploy with a different hash.
1170
+
- **[By account](../smart-contracts/global-contracts.md#reference-by-account):** The contract code is tied to another account.
1171
+
- **[By hash](../smart-contracts/global-contracts.md#reference-by-hash):** You reference the contract by its immutable code hash.
0 commit comments