首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypedError:无法在网络测试网上为帐户andrius.testnet签名事务,在InMemorySigner中找不到匹配的密钥对

TypedError:无法在网络测试网上为帐户andrius.testnet签名事务,在InMemorySigner中找不到匹配的密钥对
EN

Stack Overflow用户
提问于 2022-05-31 12:53:10
回答 1查看 189关注 0票数 1

当我试图在近api-js库上调用我的create_account函数时:

代码语言:javascript
复制
        await creatorAccount.functionCall({
            contractId: process.env.NEAR_NETWORK_ID || "",
            methodName: "create_account",
            args: {
                new_account_id: newAccount,
                new_public_key: publicKey,
            },
            gas: new BN("300000000000000"),
            attachedDeposit: new BN("10000000000000000000"),
        });

最后我得到了一个例外:

代码语言:javascript
复制
>  {"severity":"INFO","message":"KeyStore:  /var/folders/f4/qjf99cc92k5gm4n45c98h5480000gn/T"}
i  functions: Beginning execution of "api"
>  {"severity":"INFO","message":"Signer account:  /var/folders/f4/qjf99cc92k5gm4n45c98h5480000gn/T/andrius.testnet.json exists: true"}
>  {"severity":"ERROR","message":"Exception:  TypedError: Can not sign transactions for account andrius.testnet on network testnet, no matching key pair found in InMemorySigner(UnencryptedFileSystemKeyStore(/var/folders/f4/qjf99cc92k5gm4n45c98h5480000gn/T)).\n    at Account.signTransaction (/Users/bacis/Development/Catch/backend/functions/node_modules/near-api-js/lib/account.js:93:19)\n    at async /Users/bacis/Development/Catch/backend/functions/node_modules/near-api-js/lib/account.js:118:34\n    at async Object.exponentialBackoff [as default] (/Users/bacis/Development/Catch/backend/functions/node_modules/near-api-js/lib/utils/exponential-backoff.js:7:24)\n    at async Account.signAndSendTransactionV2 (/Users/bacis/Development/Catch/backend/functions/node_modules/near-api-js/lib/account.js:117:24)\n    at async createAccount (/Users/bacis/Development/Catch/backend/functions/lib/lib/nearApi.js:61:9)\n    at async account (/Users/bacis/Development/Catch/backend/functions/lib/routes/account.js:13:9) {\n  type: 'KeyNotFound',\n  context: undefined\n}"}
>  /Users/bacis/Development/Catch/backend/functions/lib/routes/account.js:17
>          throw new Error(`Account creation error: ${ex}`);

我添加了一些日志,以确认签名者帐户确实存在于该路径上:

> {"severity":"INFO","message":"Signer account: /var/folders/f4/qjf99cc92k5gm4n45c98h5480000gn/T/andrius.testnet.json exists: true"}

我还没有完全弄清楚问题出在哪里,有人有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2022-06-13 05:27:56

我通过从内存中加载私钥字符串来解决这个问题:

代码语言:javascript
复制
const keyStore = new keyStores.InMemoryKeyStore();
const keyPair = KeyPair.fromString(PRIVATE_KEY);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72448164

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档