Hello, while watching workshop I got problem with keypair of ed25519. I’ve created new wallet, took private key, but when I try to extract address I get error. Here’s my code:
import {
TransactionBlock,
Ed25519Keypair,
RawSigner,
JsonRpcProvider,
testnetConnection
} from "./node_modules/@mysten/sui.js";
dotenv.config();
const check = 1;
const secretKey = process.env.SECRET_KEY as string;
const keyPair = Ed25519Keypair.fromSecretKey(Buffer.from(secretKey, "base64"));
const provider = new JsonRpcProvider(testnetConnection);
const signer = new RawSigner(keyPair, provider);
async function main() {
const sender = await signer.getAddress();
console.log(sender);
// const tx = new TransactionBlock();
// tx.transferObjects()
}
And here’s my error:
C:\Users\admin\Desktop\sui_work\node_modules@mysten\sui.js\src\cryptography\ed25519-keypair.ts:86
throw new Error(
^
Error: Wrong secretKey size. Expected 32 bytes, got 48.
at Function.fromSecretKey (C:\Users\admin\Desktop\sui_work\node_modules@mysten\sui.js\src\cryptography\ed25519-keypair.ts:86:13)
at Object. (C:\Users\admin\Desktop\sui_work\simple-tx.ts:13:32)
at Module._compile (node:internal/modules/cjs/loader:1218:14)
at Module.m._compile (C:\Users\admin\AppData\Roaming\nvm\v18.13.0\node_modules\ts-node\src\index.ts:1618:23)
at Module._extensions…js (node:internal/modules/cjs/loader:1272:10)
at Object.require.extensions. [as .ts] (C:\Users\admin\AppData\Roaming\nvm\v18.13.0\node_modules\ts-node\src\index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1081:32)
at Function.Module._load (node:internal/modules/cjs/loader:922:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at phase4 (C:\Users\admin\AppData\Roaming\nvm\v18.13.0\node_modules\ts-node\src\bin.ts:649:14)