Skip to content

Add using global contracts option to primitives (ft, nft, dao) #2690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions docs/primitives/dao.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import CLIGetProposalList from "@site/src/components/docs/primitives/dao/near-cl
import CLICreateDAO from "@site/src/components/docs/primitives/dao/near-cli/create-dao.md"
import CLICreateProposal from "@site/src/components/docs/primitives/dao/near-cli/create-proposal.md"
import CLIVoteForProposal from "@site/src/components/docs/primitives/dao/near-cli/vote-for-proposal.md"
import CLIDeployContractUsingGlobalAccountId from "@site/src/components/docs/primitives/dao/near-cli/deploy-using-global-account-id.md"
import CLIDeployContractUsingGlobalHash from "@site/src/components/docs/primitives/dao/near-cli/deploy-using-global-hash.md"

import LantstoolGetDAOList from "@site/src/components/docs/primitives/dao/lantstool/get-dao-list.md"
import LantstoolGetProposalList from "@site/src/components/docs/primitives/dao/lantstool/get-proposal-list.md"
Expand Down Expand Up @@ -55,6 +57,7 @@ easily generalizable to other DAO implementations.
## Create a DAO
The simplest way to create and interact with a DAO is to go through the [AstraDAO UI](https://near.social/astraplusplus.ndctools.near/widget/home?page=daos).

### Using Sputnik DAO Contract
You can also create a DAO by interacting with the `sputnik-dao` contract.

<Tabs groupId="code-tabs">
Expand All @@ -74,6 +77,29 @@ You can also create a DAO by interacting with the `sputnik-dao` contract.

<hr className="subsection" />

### Using Global Contract

You can find out what global contracts are [here](../smart-contracts/global-contracts.md). But in short, global contracts allow smart contracts to be deployed once and reused by any account without incurring high storage costs.

In other words, you can deploy a DAO contract using our global DAO contract, which is already deployed and basically is just [a Sputnik DAO contract](https://github.com/near-daos/sputnik-dao-contract/tree/main/sputnikdao2) without any customization. You need only to call the following deploying command with your initialization parameters.

<Tabs groupId="code-tabs">
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Deploy by account id:
<CLIDeployContractUsingGlobalAccountId />
Deploy by hash:
<CLIDeployContractUsingGlobalHash />
</TabItem>
</Tabs>

:::note
The difference between global contracts deployed by account id and by hash is that the former is updatable, while the latter is immutable. When it's deployed by account id, the owner can redeploy the contract updating it for all its users.

So when you decide which option to use for deploying your DAO contract, you should consider whether you want to it to be updatable by its original owner or not.
:::

<hr className="subsection" />

### Voting policy
Currently, DAOs support two different types of [voting policies](https://github.com/near-daos/sputnik-dao-contract#voting-policy): `TokenWeight`, and `RoleWeight`.

Expand Down
39 changes: 36 additions & 3 deletions docs/primitives/ft.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import CLIRegister from "@site/src/components/docs/primitives/ft/near-cli/regist
import CLIAttachTokenToCall from "@site/src/components/docs/primitives/ft/near-cli/attach-to-call.md"
import CLICreateToken from "@site/src/components/docs/primitives/ft/near-cli/create.md"
import CLICreateTokenManually from "@site/src/components/docs/primitives/ft/near-cli/create-manually.md"
import CLICreateTokenUsingGlobalAccountId from "@site/src/components/docs/primitives/ft/near-cli/create-using-global-account-id.md"
import CLICreateTokenUsingGlobalHash from "@site/src/components/docs/primitives/ft/near-cli/create-using-global-hash.md"

import SmartContractSendToken from "@site/src/components/docs/primitives/ft/smart-contract/send.md"
import SmartContractAttachTokenToCall from "@site/src/components/docs/primitives/ft/smart-contract/attach-to-call.md"
Expand All @@ -48,7 +50,15 @@ In order for a contract to be considered a FT-contract it has to follow the [**N

---

## Token Factory Tool
## Create New Token

There are three ways to create a fungible token (FT) on NEAR:

1. Using the **[Token Factory Tool](#token-factory-tool)**, a tool to create a FT contract through graphical interface, or by making calls to its contract.
2. **Deploying [your own FT Contract](#deploying-your-own-contract)**: Writing and deploying your own FT contract from scratch.
3. **Deploying a token [using Global Contract](#deploying-a-token-using-global-contract)**: Writing and deploying your own FT contract from scratch.

### Token Factory Tool
You can create an FT using the toolbox on [Dev Portal](https://dev.near.org/tools). The FT Tool is a token factory, you can interact with it through graphical interface, or by making calls to its contract.

<Tabs groupId="code-tabs">
Expand All @@ -65,9 +75,9 @@ You can create an FT using the toolbox on [Dev Portal](https://dev.near.org/tool

The FT you create will live in the account `<your_token_symbol>.tkn.primitives.near` (e.g. `test.tkn.primitives.near`).

---
<hr class="subsection" />

## Deploying Your Own Contract
### Deploying Your Own Contract

You can also create a fungible token by deploying and initializing a [canonical FT contract](https://github.com/near-examples/FT).

Expand All @@ -89,6 +99,29 @@ To initialize a FT contract you will need to deploy it and then call the `new` m
Check the [Contract Wizard](https://dev.near.org/contractwizard.near/widget/ContractWizardUI) to create a personalized FT contract!.
:::

<hr class="subsection" />

### Deploying a Token Using Global Contract

You can find out what global contracts are [here](../smart-contracts/global-contracts.md). But in short, global contracts allow smart contracts to be deployed once and reused by any account without incurring high storage costs.

In other words, you can deploy a FT contract using our global FT contract, which is already deployed and basically is just [a standard FT contract](https://github.com/near-examples/FT) without any customization. You need only to call the following deploying command with your initialization parameters.

<Tabs groupId="code-tabs">
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Deploy by account id:
<CLICreateTokenUsingGlobalAccountId />
Deploy by hash:
<CLICreateTokenUsingGlobalHash />
</TabItem>
</Tabs>

:::note
The difference between global contracts deployed by account id and by hash is that the former is updatable, while the latter is immutable. When it's deployed by account id, the owner can redeploy the contract updating it for all its users.

So when you decide which option to use for deploying your FT contract, you should consider whether you want to it to be updatable by its original owner or not.
:::

---

## Querying Metadata
Expand Down
30 changes: 29 additions & 1 deletion docs/primitives/nft.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import CLIBuyNFT from "@site/src/components/docs/primitives/nft/near-cli/buy.md"
import CLIQueryNFT from "@site/src/components/docs/primitives/nft/near-cli/query.md"
import CLITransferNFT from "@site/src/components/docs/primitives/nft/near-cli/transfer.md"
import CLIListNFTForSale from "@site/src/components/docs/primitives/nft/near-cli/list-for-sale.md"
import CLIDeployContractUsingGlobalAccountId from "@site/src/components/docs/primitives/nft/near-cli/deploy-using-global-account-id.md"
import CLIDeployContractUsingGlobalHash from "@site/src/components/docs/primitives/nft/near-cli/deploy-using-global-hash.md"

import LantstoolMintNFT from "@site/src/components/docs/primitives/nft/lantstool/mint.md"
import LantstoolBuyNFT from "@site/src/components/docs/primitives/nft/lantstool/buy.md"
Expand Down Expand Up @@ -66,7 +68,10 @@ The easiest way to create and handle NFTs is by using one of the existing commun
---

## Deploying a NFT Contract
If you want to deploy your own NFT contract, you can create one using our [reference implementation](https://github.com/near-examples/NFT)

### Deploying Your Own Contract

If you want to deploy your own NFT contract, you can create one using our [reference implementation](https://github.com/near-examples/NFT).

Simply personalize it and deploy it to your account.

Expand All @@ -89,6 +94,29 @@ Check the [Contract Wizard](https://dev.near.org/contractwizard.near/widget/Cont

:::

<hr class="subsection" />

### Deploying Using Global Contract

You can find out what global contracts are [here](../smart-contracts/global-contracts.md). But in short, global contracts allow smart contracts to be deployed once and reused by any account without incurring high storage costs.

In other words, you can deploy a NFT contract using our global NFT contract, which is already deployed and basically is just [a standard NFT contract](https://github.com/near-examples/NFT) without any customization. You need only to call the following deploying command with your initialization parameters.

<Tabs groupId="code-tabs">
<TabItem value="🖥️ CLI" label="🖥️ CLI">
Deploy by account id:
<CLIDeployContractUsingGlobalAccountId />
Deploy by hash:
<CLIDeployContractUsingGlobalHash />
</TabItem>
</Tabs>

:::note
The difference between global contracts deployed by account id and by hash is that the former is updatable, while the latter is immutable. When it's deployed by account id, the owner can redeploy the contract updating it for all its users.

So when you decide which option to use for deploying your NFT contract, you should consider whether you want to it to be updatable by its original owner or not.
:::

---

## Minting a NFT
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
```bash
near contract deploy <account-id> use-global-account-id dao.globals.primitives.testnet \
with-init-call new \
json-args '{"config": {"name": "Primitives", "purpose": "Building primitives on NEAR", "metadata":""}, "policy": ["<account-id>"]}' \
prepaid-gas '100.0 Tgas' \
attached-deposit '0 NEAR' \
network-config testnet \
sign-with-keychain \
send
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
```bash
near contract deploy <account-id> use-global-hash Ea8tHXFSQVszVwGASyzAfLq65DjcRDhkfab4FcPaRpgD \
with-init-call new \
json-args '{"config": {"name": "Primitives", "purpose": "Building primitives on NEAR", "metadata":""}, "policy": ["<account-id>"]}' \
prepaid-gas '100.0 Tgas' \
attached-deposit '0 NEAR' \
network-config testnet \
sign-with-keychain \
send
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
```bash
near contract deploy <account-id> use-global-account-id ft.globals.primitives.testnet \
with-init-call \
new_default_meta \
json-args '{"owner_id": "<account-id>", "total_supply": "100000000000000000000000000000"}' \
prepaid-gas '100.0 Tgas' \
attached-deposit '0 NEAR' \
network-config testnet \
sign-with-keychain send
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
```bash
near contract deploy <account-id> use-global-hash 3vaopJ7aRoivvzZLngPQRBEd8VJr2zPLTxQfnRCoFgNX \
with-init-call \
new_default_meta \
json-args '{"owner_id": "<account-id>", "total_supply": "100000000000000000000000000000"}' \
prepaid-gas '100.0 Tgas' \
attached-deposit '0 NEAR' \
network-config testnet \
sign-with-keychain send
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
```bash
near contract deploy <account-id> use-global-account-id nft.globals.primitives.testnet \
with-init-call new \
json-args '{"owner_id": "<account-id>", "metadata": {"spec": "nft-1.0.0", "name": "MY_NFT", "symbol": "NFT2000", "icon": "data:image/svg+xml,%3Csvg xmlns='\''http://www.w3.org/2000/svg'\'' viewBox='\''0 0 288 288'\''%3E%3Cg id='\''l'\'' data-name='\''l'\''%3E%3Cpath d='\''M187.58,79.81l-30.1,44.69a3.2,3.2,0,0,0,4.75,4.2L191.86,103a1.2,1.2,0,0,1,2,.91v80.46a1.2,1.2,0,0,1-2.12.77L102.18,77.93A15.35,15.35,0,0,0,90.47,72.5H87.34A15.34,15.34,0,0,0,72,87.84V201.16A15.34,15.34,0,0,0,87.34,216.5h0a15.35,15.35,0,0,0,13.08-7.31l30.1-44.69a3.2,3.2,0,0,0-4.75-4.2L96.14,186a1.2,1.2,0,0,1-2-.91V104.61a1.2,1.2,0,0,1,2.12-.77l89.55,107.23a15.35,15.35,0,0,0,11.71,5.43h3.13A15.34,15.34,0,0,0,216,201.16V87.84A15.34,15.34,0,0,0,200.66,72.5h0A15.35,15.35,0,0,0,187.58,79.81Z'\''/%3E%3C/g%3E%3C/svg%3E"}}' \
prepaid-gas '100.0 Tgas' \
attached-deposit '0 NEAR' \
network-config testnet \
sign-with-keychain \
send
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
```bash
near contract deploy <account-id> use-global-hash ivu1e9obVRnMJLSvVPRgtYefUYUS1L3f5eYHjS86zL9 \
with-init-call new \
json-args '{"owner_id": "<account-id>", "metadata": {"spec": "nft-1.0.0", "name": "MY_NFT", "symbol": "NFT2000", "icon": "data:image/svg+xml,%3Csvg xmlns='\''http://www.w3.org/2000/svg'\'' viewBox='\''0 0 288 288'\''%3E%3Cg id='\''l'\'' data-name='\''l'\''%3E%3Cpath d='\''M187.58,79.81l-30.1,44.69a3.2,3.2,0,0,0,4.75,4.2L191.86,103a1.2,1.2,0,0,1,2,.91v80.46a1.2,1.2,0,0,1-2.12.77L102.18,77.93A15.35,15.35,0,0,0,90.47,72.5H87.34A15.34,15.34,0,0,0,72,87.84V201.16A15.34,15.34,0,0,0,87.34,216.5h0a15.35,15.35,0,0,0,13.08-7.31l30.1-44.69a3.2,3.2,0,0,0-4.75-4.2L96.14,186a1.2,1.2,0,0,1-2-.91V104.61a1.2,1.2,0,0,1,2.12-.77l89.55,107.23a15.35,15.35,0,0,0,11.71,5.43h3.13A15.34,15.34,0,0,0,216,201.16V87.84A15.34,15.34,0,0,0,200.66,72.5h0A15.35,15.35,0,0,0,187.58,79.81Z'\''/%3E%3C/g%3E%3C/svg%3E"}}' \
prepaid-gas '100.0 Tgas' \
attached-deposit '0 NEAR' \
network-config testnet \
sign-with-keychain \
send
```
Loading