Batch actions from within an AssemblyScript contract
(1) transfer money
// assume Context.sender = "bob.testnet"
ContractPromiseBatch.create("alice.testnet").transfer(100); // send 100 N to "alice.testnet"
(2) deploy a contract
// assume contract is loaded, either included and encoded as base64 in the current
// contract itself or via input to a function call (requires some other changes in near-sdk-as)
const code = Uint8Array[1,2,3]; // regardless, you end up with the contract code somehow
// assume Context.sender = "bob.testnet"
ContractPromiseBatch
.create("app-v1.bob.testnet")
.create_account()
.transfer(u128.from(100))
.add_full_access_key(new Uint8Array(0)) // TODO: need signer public key as byte array
.deploy_contract(code)
(3) chain promises
// assume Context.sender = "bob.testnet"
let promise = ContractPromiseBatch.create("first-contract.bob.testnet")
Batch actions from within an AssemblyScript contract
(1) transfer money
// assume Context.sender = "bob.testnet" ContractPromiseBatch.create("alice.testnet").transfer(100); // send 100 N to "alice.testnet"
(2) deploy a contract
// assume contract is loaded, either included and encoded as base64 in the current // contract itself or via input to a function call (requires some other changes in near-sdk-as) const code = Uint8Array[1,2,3]; // regardless, you end up with the contract code somehow
// assume Context.sender = "bob.testnet"
ContractPromiseBatch .create("app-v1.bob.testnet") .create_account() .transfer(u128.from(100)) .add_full_access_key(new Uint8Array(0)) // TODO: need signer public key as byte array .deploy_contract(code)
(3) chain promises
// assume Context.sender = "bob.testnet"
let promise = ContractPromiseBatch.create("first-contract.bob.testnet")
promise.then("first-contract.bob.testnet") .transfer(u128.from(10))