【发布时间】:2021-04-16 14:59:32
【问题描述】:
near deploy 命令需要对其部署到的帐户的完整访问密钥。
一个人如何创建新帐户并为其部署合同,而无需继续访问该帐户?例如NEAR 术语中的“锁定”合约。
【问题讨论】:
near deploy 命令需要对其部署到的帐户的完整访问密钥。
一个人如何创建新帐户并为其部署合同,而无需继续访问该帐户?例如NEAR 术语中的“锁定”合约。
【问题讨论】:
目前的方法是通过near repl。
这会启动一个 JS 控制台,您可以在其中粘贴如下代码:
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"),
]);
<your account> 是您在本地拥有密钥的帐户。
这将在单个事务中创建新帐户 <sub account>.<your account>,转移 100N,从 <contract path> 部署合约并使用给定参数调用 new 方法。因此,作为部署者,除了作为 API 提供的合约之外,您将无法访问此合约。
【讨论】:
near create-account <accountId>
near deploy [accountId] [wasmFile] [initFunction] [initArgs] [initGas] [initDeposit]
near delete-key <account-id> <access-key>
检查现有密钥:near keys <accountId>
这在引入工厂之前适用于 NEAR betanet 质押池。
【讨论】: