我正在尝试使用Aptos类型记录SDK创建一个令牌集合。
const account = new AptosAccount(Uint8Array.from(Buffer.from(PRIVATE_KEY)), ACCOUNT_ADDR);
await tokenClient.createCollection(
account,
"A test collection 1",
"A test collection",
"https://google.com",
);但我得到了以下错误:
ApiError2: {"message":"Invalid transaction: Type: Validation Code: INVALID_AUTH_KEY","error_code":"vm_error","vm_error_code":2}
我做错了什么?
尝试复制Aptos的官方例子,但我不创建一个新的帐户,我想使用一个现有的资金帐户。
发布于 2022-11-21 10:59:49
假设您有一个私钥作为十六进制字符串,您可以这样做:
import { AptosAccount, HexString } from "aptos";
const privateKeyHex = "0xdcaf65ead38f7cf0eb4f81961f8fc7f9b7f1e2f45e2d4a6da0dbef85f46f6057";
const privateKeyBytes = HexString.ensure(privateKeyHex).toUint8Array();
const account = new AptosAccount(privateKeyBytes);发布于 2022-11-24 09:20:53
我也有过同样的问题。最后,我发现问题在于与private_key不匹配的地址,而private_key不是ed25519格式的。您的密钥必须使用ed25519曲线生成,然后您应该根据该键创建您的地址。然后,我使用bip_utils库创建了bip_private_key (使用ed25519协议):
private_key = ed25519.PrivateKey.from_hex(bip_private_key)发布于 2022-11-29 07:15:34
我只想向Daniel's answer添加一些细节,说明如何在创建钱包之后获得私钥,然后使用它:
import { AptosAccount } from "aptos";
const wallet = new AptosAccount();
const privateKeyHex = wallet.toPrivateKeyObject().privateKeyHex;
// ...
const privateKeyBytes = HexString.ensure(privateKeyHex).toUint8Array();
const account = new AptosAccount(privateKeyBytes);https://stackoverflow.com/questions/74511179
复制相似问题