当我试图在近api-js库上调用我的create_account函数时:
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"),
});最后我得到了一个例外:
> {"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"}
我还没有完全弄清楚问题出在哪里,有人有什么想法吗?
发布于 2022-06-13 05:27:56
我通过从内存中加载私钥字符串来解决这个问题:
const keyStore = new keyStores.InMemoryKeyStore();
const keyPair = KeyPair.fromString(PRIVATE_KEY);https://stackoverflow.com/questions/72448164
复制相似问题