or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
Sputnik v2 Smart Contract Documentation
DenysK is providing raw commands for the following actions:
TODO:
Useful References
Deploy a new DAO with Sputnik v2 Factory
git clone https://github.com/near-daos/sputnik-dao-contract && cd sputnik-dao-contract/sputnikdao-factory2
./build.sh
export NEAR_ENV=testnet && near deploy sputnik.testnet --wasmFile res/sputnikdao_factory2.wasm --accountId sputnik.testnet
export CONTRACT_ID="sputnik.testnet"
near call $CONTRACT_ID new --accountId $CONTRACT_ID
Create a new DAO with default parameters / call factory create method to create a new DAO, can be executed by any NEAR account.
a. create base64 encoded string of arguments to provide to Sputnik DAO contract call:
b. create DAO
near call $CONTRACT_ID create "{\"name\": \"genesis\", \"args\": \"ARGS\"}" --accountId your_account.testnet --amount 5 --gas 150000000000000
attach minimum 150000000000000 of gas a new DAO will be created with following defaults:
Add proposal, type A - Council member
near call genesis.sputnik.testnet add_proposal '{"proposal": {"description": "Add New Council", "kind": {"AddMemberToRole": {"member_id": "council_member_3.testnet", "role": "council"}}}}' --accountId proposer.testnet --amount 1
record ID returned from this call.
Approve proposal by council member
near call genesis.sputnik.testnet act_proposal '{"id": ID_from_previous_call, "action": "VoteApprove"}' --accountId council_member_1.testnet
Call arbitrary functions on other contracts
Example to create a FT from the DAO
Token factory
Build token factory
git clone https://github.com/evgenykuzyakov/token-factory
orgit clone https://github.com/near-examples/token-factory
cd token-factory/contracts && ./build.sh
near deploy your_token_factory.testnet --wasmFile factory/res/token_factory.wasm --accountId your_token_factory.testnet
Or use exiting one: testnet:
tokenfactory.testnet
, mainnet:tkn.near
Prepare token arguments and metadata
token specification:
total_supply
- the total number of tokens in circulation. Example: The 1000 tokens is 1000 * 10^18 or as a number is 1000000000000000000000, referencedecimals
- used in frontends to show the proper significant digits of a token, the precision ("decimals" in this metadata standard), reference: https://nomicon.io/Standards/FungibleToken/Metadata.htmlicon
- a small image associated with this token. Must be a data URL, to help consumers display it quickly while protecting user data.name
- the human-readable name of the token.symbol
- the abbreviation, like wETH or AMPL.please refer to nomicon.io/Standards/FungibleToken/ for more details
Create proposal for the new token
near call your_dao.testnet add_proposal "{\"proposal\": {\"description\": \"Create a new token\", \"kind\": {\"FunctionCall\": {\"receiver_id\": \"your_token_factory.testnet\", \"actions\": [{\"method_name\": \"create_token\", \"args\": \"ARGS\", \"deposit\": \"3000000000000000000000000\", \"gas\": \"20000000000000\"}]}}}}" --accountId proposer_account.testnet --amount 5
Act on proposal
near call genesis.sputnik.testnet act_proposal '{"id": ID_from_previous_step, "action": "VoteApprove"}' --accountId council_member_account.testnet --gas 250000000000000
Please note, that successful execution of #5 does not mean successful token creating, you have to check the expolorer by using URL provided in result of #5 and check if token was successfully created.
Adopting a voting token
Setup staking contract
In order to setup staking contract you need to deploy it on new NEAR account. We choose the option to utilise generic-factory to achive this, this approach can be used in the frontend
Please review factory here: https://github.com/near/core-contracts/tree/generic-factory/generic-factory
We have deployed the factory on the testnet and will be using this account in examples: generic.testnet, below the deployment code:
near call generic.testnet create '{"name": "sputnik-staking","hash": "4ThdGjTKbBTad45CyePPAiZmWJEpEoFwViFusy4cpEmA","Cg== ": "","access_keys": ["<FULL_ACCESS_KEY>"]}' --accountId your_account.testnet --amount 5
result:

near call sputnik-staking.generic.testnet new '{"token_id": "<token created before>","owner_id": "<dao created before>", "unstake_period": "604800000000000"}' --accountId solo.testnet
storage_deposit
functionnear call bst.tokenfactory.testnet storage_deposit '{"account_id": "sputnik-staking.generic.testnet"}' --accountId solo.testnet --amount 1
, resultAdopt the staking contract
Make a proposal to adopt the staking contract to vote for the DAO
near call private4.sputnikv2.testnet add_proposal '{"proposal": {"description": "Adopt BST token for voting", "kind": {"SetStakingContract": {"staking_id": "sputnik-staking.generic.testnet"}}}}' --accountId solo.testnet --amount 1
Approve proposal usual way
Resever storage for the token owner account on staking contract
near call sputnik-staking.generic.testnet storage_deposit '' --accountId solo.testnet --amount 0.003
Transfer token to the staking contract
near call bst.tokenfactory.testnet ft_transfer '{"receiver_id": "sputnik-staking.generic.testnet", "amount": "9000000000000000000000", "msg": ""}' --accountId starlink.testnet --amount 0.000000000000000000000001
near call putnik-staking.generic.testnet delegate '{"account_id": "starlink.testnet", "amount": "9000000000000000000000"}' --accountId starlink.testnet
Check the work
View staking contract total supply
near view private4.sputnikv2.testnet delegation_total_supply ''
View user delegation
near call private6-sputnik-staking.generic.testnet get_user '{"account_id": "sstarlink.testnet"}' --accountId starlink.testnet
Changing Policy
Add proposal to change policy
In order to change policy you need to create a proposal
ChangePolicy
type with a whole policy JSON. For better visualisation we will usenear repl
in this exampletouch change-policy.sh && chmod +x change-policy.sh
vi change-policy.sh
To check any DAO current policy, run
near view <dao account> get_policy
The default DAO policy is:
Execute file from console/terminal:
./change-policy.sh
Approve proposal:
near call private4.sputnikv2.testnet act_proposal '{"id": XX, "action": "VoteApprove"}' --accountId solo.testnet --gas 300000000000000
And check the result:
near view private4.sputnikv2.testnet get_policy ''
We have just added a new member role:
influencers
and amended roleEveryone
to allow everyone to FinaliseAdd new member to new role
Now when we have a new Role
influencers
, we can add a new member to it:near call private4.sputnikv2.testnet add_proposal '{"proposal": {"description": "Add New Influencer", "kind": {"AddMemberToRole": {"member_id": "starlink.testnet", "role": "influencers"}}}}' --accountId solo.testnet --amount 1
near call private4.sputnikv2.testnet act_proposal '{"id": XX, "action": "VoteApprove"}' --accountId solo.testnet --gas 300000000000000
near view private4.sputnikv2.testnet get_policy '