Skip to main content

Stake and Unstake Tokens

Stake

const nativeTokenAddress = Variables.NATIVE_TOKEN_ADDRESS;
const res = await fuseSDK.stakeToken(
new StakeRequestBody({
accountAddress: fuseSDK.wallet.getSender(),
tokenAmount: "0.01",
tokenAddress: nativeTokenAddress,
})
);

console.log(`UserOpHash: ${res?.userOpHash}`);
console.log("Waiting for transaction...");
const ev = await res?.wait();
console.log(
`Transaction hash: https://explorer.fuse.io/tx/${ev?.transactionHash}`
);

Unstake

const nativeTokenAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
const res = await fuseSDK.unstakeToken(
new UnstakeRequestBody({
accountAddress: fuseSDK.wallet.getSender(),
tokenAmount: "0.007",
tokenAddress: nativeTokenAddress,
}),
"0xb1DD0B683d9A56525cC096fbF5eec6E60FE79871"
);

console.log(`UserOpHash: ${res?.userOpHash}`);
console.log("Waiting for transaction...");
const ev = await res?.wait();
console.log(
`Transaction hash: https://explorer.fuse.io/tx/${ev?.transactionHash}`
);