javascript - 如何让用户在前端部署 NEAR 协议(protocol)智能合约?

标签 javascript web3 nearprotocol

接近能够让个人用户从 NEAR 的前端部署他们自己的智能合约,但我遇到了一个错误。首先,代码:

const account = await near.account('polluterofminds.testnet');
const res = await axios.get("/api/contract");
  
const contractRaw = res.data;
const uint8 = new Uint8Array(Buffer.from(contractRaw))

const result = await account.deployContract(uint8);
console.log(result);
执行此操作时,我收到以下错误:
Error: The transaction contains more then one action, but it was signed with an access key which allows transaction to apply only one specific action. To apply more then one actions TX must be signed with a full access key
不知道如何解决这个问题。据我所知我的polluterofminds.testnet帐户具有完整的访问 key ,并且我已使用该帐户登录。
有人成功做到这一点吗?

最佳答案

在这里,来自不久前创建的一个示例,该示例演示了将契约(Contract)部署到用户帐户作为通信协议(protocol)的一部分
https://github.com/metanear/metanear-web/blob/master/src/Home.js#L96
更新
(解决对此答案的评论)
@JustinHunter 有两种访问 key :FullAccess这使您可以使用所有 8 个支持的操作和 FunctionCall 签署交易。仅允许您使用一种类型签署交易的访问 key ,FunctionCall行动。
你可以在这里看到更多关于事务和操作、键等的信息:

  • https://docs.near.org/docs/concepts/transaction
  • https://docs.near.org/docs/concepts/account#access-keys

  • 以及此视频中有关此限制的一些相关词语:
    https://youtu.be/ZM7TCONx9BI?t=2127

    关于javascript - 如何让用户在前端部署 NEAR 协议(protocol)智能合约?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67777745/

    相关文章:

    blockchain - web3j 中凭证的钱包路径是什么?

    ethereum - 错误 : Returned error: The method eth_sendTransaction does not exist

    rust - 如何对余额编号进行算术运算以避免在NEAR智能合约中溢出?

    javascript - load 与 DOMContentLoaded 的区别

    javascript - 现有的 JavaScript 框架会合并 CommonJS 吗?

    javascript - Ethereum web3 sendSignedTransaction : Insufficient funds. 该帐户...没有足够的资金。需要 750000000000000 并得到:0

    nearprotocol - 处理来自nearlib的账户和交易签名

    javascript - 在 JavaScript 中获取真实元素的宽度

    javascript - var foo = foo ||警报(富);

    nearprotocol - 跨合约调用是原子的吗?