Sign Transaction Aptos
Signing on your side, Code Example
ts
try {
// import aptos lib
import aptos from "aptos";
// import SDK
import { NODE_URL, createClient, stake } from '@everstake/wallet-sdk/aptos';
// Optional
// 1. create client using aptos lib
// Node url you can use custom or import him
const client = new aptos.AptosClient(NODE_URL);
// 2. or create client using func createClient
// const client = createClient(NODE_URL);
// get UserAccount using user privateKey
const Uint8Array = aptos.HexString.ensure(privateKey).toUint8Array();
const UserAccount = new aptos.AptosAccount(Uint8Array);
// Raw Transaction
const txnRequest = await Aptos.stake(token, address, amount);
// Sign Transaction
const signedTxn = await client.signTransaction(UserAccount, txnRequest);
const transactionRes = await client.submitTransaction(signedTxn);
await client.waitForTransaction(transactionRes.hash);
return transactionRes.hash; // return hash
} catch (error) {
throw new Error(error);
}