Giter Site home page Giter Site logo

near_contract_rust-did's Introduction

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

near_contract_rust-did's People

Contributors

lk2684753 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.