Skip to content

Commit 0c9a344

Browse files
committed
update
1 parent b93e776 commit 0c9a344

File tree

3 files changed

+31
-15
lines changed

3 files changed

+31
-15
lines changed

docs/smart-contracts/global-contracts.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,23 @@ import TabItem from '@theme/TabItem';
88

99
Global contracts allow smart contracts to be deployed once and reused by any account without incurring high storage costs.
1010

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.
1228

1329
## Deploying a Global Contract
1430

docs/tools/near-api.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ To allow users to login into your web application using a wallet you will need t
8181

8282
<Tabs groupId="api">
8383
<TabItem value="js" label="🌐 JavaScript">
84-
You can use the API library in the browser, or in Node.js runtime.
84+
You can use the API library in the browser, or in Node.js runtime.
8585

8686
```js
8787
import { Account } from "@near-js/accounts";
@@ -151,7 +151,7 @@ To allow users to login into your web application using a wallet you will need t
151151

152152
<hr class="subsection" />
153153

154-
### Key Handlers: Stores & Signers
154+
### Key Handlers: Stores & Signers
155155

156156
<Tabs groupId="api">
157157
<TabItem value="js" label="🌐 JavaScript">
@@ -587,7 +587,7 @@ When creating a new account, you’ll need to provide:
587587
await account.createAccount(
588588
"another_user.testnet",
589589
keyPair.getPublicKey(),
590-
// attaches 1.234 NEAR tokens that will become
590+
// attaches 1.234 NEAR tokens that will become
591591
// an initial balance of "another_user.testnet"
592592
NEAR.toUnits("1.234")
593593
);
@@ -610,7 +610,7 @@ When creating a new account, you’ll need to provide:
610610
await account.createAccount(
611611
"another_user.testnet",
612612
publicKey,
613-
// attaches 1.234 NEAR tokens that will become
613+
// attaches 1.234 NEAR tokens that will become
614614
// an initial balance of "another_user.testnet"
615615
NEAR.toUnits("1.234")
616616
);
@@ -676,7 +676,7 @@ To create a sub-account, the parent must send a transaction to itself with the [
676676
await account.createAccount(
677677
"project.user.testnet",
678678
keyPair.getPublicKey(),
679-
// attaches 1.234 NEAR tokens that will become
679+
// attaches 1.234 NEAR tokens that will become
680680
// an initial balance of "project.user.testnet"
681681
NEAR.toUnits("1.234")
682682
);
@@ -728,7 +728,7 @@ Deleting an account **DOES NOT** affect its sub-accounts - they will remain acti
728728
```js
729729
const account = new Account("user.testnet", provider, signer);
730730
731-
// account "user.testnet" gets deleted
731+
// account "user.testnet" gets deleted
732732
// and remaining funds will go to account "beneficiary.testnet" (if it exists)
733733
await account.deleteAccount("beneficiary.testnet");
734734
```
@@ -764,7 +764,7 @@ Accounts can transfer different types of tokens to other accounts, including the
764764
<Tabs groupId="api">
765765
<TabItem value="js" label="🌐 JavaScript">
766766

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.
768768

769769
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.
770770
@@ -874,7 +874,7 @@ A smart contract exposes its methods, and making a function call that modifies s
874874
<Tabs groupId="api">
875875
<TabItem value="js" label="🌐 JavaScript">
876876

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.
878878

879879
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.
880880

@@ -1164,13 +1164,11 @@ Unlike many other blockchains, contracts on NEAR are mutable, meaning you have t
11641164
11651165
### Deploy a Global Contract {#deploy-a-global-contract}
11661166
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.
11701168
11711169
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.
11741172
11751173
<Tabs groupId="api">
11761174
<TabItem value="js" label="🌐 JavaScript">

website/sidebars.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ const sidebar = {
212212
],
213213
},
214214
{
215-
Advanced: ['smart-contracts/global-contracts'],
215+
'Advanced': [
216+
'smart-contracts/global-contracts'
217+
],
216218
},
217219
'resources/contracts-list'
218220
],

0 commit comments

Comments
 (0)