Currently the way to do it is via near repl
.
This starts a JS console, where you can paste code like this:
const fs = require('fs');
const account = await near.account("<your account>");
const contractName = "<sub account>.<your account>";
const newArgs = {...args...};
const result = account.signAndSendTransaction(
contractName,
[
nearAPI.transactions.createAccount(),
nearAPI.transactions.transfer("100000000000000000000000000"),
nearAPI.transactions.deployContract(fs.readFileSync("<contract path>")),
nearAPI.transactions.functionCall("new", Buffer.from(JSON.stringify(newArgs)), 10000000000000, "0"),
]);
Where <your account>
is an account you have keys locally for.
This will in a single transaction create new account <sub account>.<your account>
, transfer 100N, deploy contract from <contract path>
and call new
method with given args. As a result, as a deployer you will not have any access to this contract outside of what contract provides as API.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…