NEAR Protocol

You can use the Near Protocol in Directual scenarios. We offer support for both the mainnet and testnet environments.

Using NEAR in JS SDK

DirectualEngine.addEventListener(AppEvents.START, function(context){

  var network = "testnet" // or "mainnet"
  var masterAddress = "account...name.near"
  var masterPrivateKey = "ed25519:2zSB....HQfB45"
  
  //get wallet instnace
  var wallet = $D.crypto.near.wallet(network, masterAddress, masterPrivateKey)
  var balance = wallet.getBalance(); // return balance in NEARs: 188.0431168340027667
  
  wallet.send('address', "0.1") // send 0.1 NEAR on address
  
  //create new wallet from master account
  var newWallet = $D.crypto.near.create(network, masterAddress, masterPrivateKey)
  //newWallet.address - address
  //newWallet.privateKey - key
  
  //send 0.1 Near from main wallet to new wallet address
  wallet.send(newWallet.address, "0.1")
 
  //get last transaction liked with it account
  newWallet.getTransaction().forEach(function(tx){
     $D.console.log(tx)
  })
  
  
  
  return true;
});

Last updated