Skip to content

Learn-NEAR-Club/near_contract_rust-did

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Near_Contract_Rust-DiD

The near DID contract implemented by rust

Building

To build run:

env 'RUSTFLAGS=-C link-arg=-s' cargo build --target wasm32-unknown-unknown --release

Using this contract

This smart contract will get deployed to your NEAR account. For this example, please create a new NEAR account. Because NEAR allows the ability to upgrade contracts on the same account, initialization functions must be cleared. If you'd like to run this example on a NEAR account that has had prior contracts deployed, please use the near-cli command near delete, and then recreate it in Wallet. To create (or recreate) an account, please follow the directions on NEAR Wallet.

Switch to mainnet. You can skip this step to use testnet as a default network.

export NEAR_ENV=mainnet

In the project root, log in to your newly created account with near-cli by following the instructions after this command:

near login

To make this tutorial easier to copy/paste, we're going to set an environment variable for your account id. In the below command, replace MY_ACCOUNT_NAME with the account name you just logged in with, including the .near:

ID=MY_ACCOUNT_NAME

You can tell if the environment variable is set correctly if your command line prints the account name after this command:

echo $ID

Create account:

near create-account did.$ID --masterAccount $ID --initialBalance 20

Example

Now we can deploy the compiled contract in this example to your account:

near deploy --wasmFile target/wasm32-unknown-unknown/release/did.wasm  --accountId did.$ID

Register a DID identity:

near call did.$ID  reg_did_using_account --accountId $ID

Check the DID identity. (Did:NEAR: Your NEAR account):

near call did.$ID  get_document  '{"did":"did:near:$ID"}' --accountId $ID

Add the controller:

near call did.$ID  add_controller  '{"controller":"did:near:$ID"}'   --accountId $ID

About

The near DID contract implemented by rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%