【问题标题】:How to deploy locked contract on NEAR如何在 NEAR 上部署锁定合约
【发布时间】:2021-04-16 14:59:32
【问题描述】:

near deploy 命令需要对其部署到的帐户的完整访问密钥。 一个人如何创建新帐户并为其部署合同,而无需继续访问该帐户?例如NEAR 术语中的“锁定”合约。

【问题讨论】:

    标签: blockchain nearprotocol


    【解决方案1】:

    目前的方法是通过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"),
        ]);
    

    &lt;your account&gt; 是您在本地拥有密钥的帐户。 这将在单个事务中创建新帐户 &lt;sub account&gt;.&lt;your account&gt;,转移 100N,从 &lt;contract path&gt; 部署合约并使用给定参数调用 new 方法。因此,作为部署者,除了作为 API 提供的合约之外,您将无法访问此合约。

    【讨论】:

      【解决方案2】:
      • 创建子账号

      near create-account &lt;accountId&gt;

      • 部署合约

      near deploy [accountId] [wasmFile] [initFunction] [initArgs] [initGas] [initDeposit]

      • 删除帐户中的访问密钥

      near delete-key &lt;account-id&gt; &lt;access-key&gt;

      检查现有密钥:near keys &lt;accountId&gt;

      这在引入工厂之前适用于 NEAR betanet 质押池。

      【讨论】:

        猜你喜欢
        • 2021-01-14
        • 2021-08-18
        • 2021-06-13
        • 2021-06-14
        • 1970-01-01
        • 2023-03-10
        • 1970-01-01
        • 1970-01-01
        • 2019-12-10
        相关资源
        最近更新 更多