Stake and Unstake Tokens
Stake
- Web
- Flutter
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}`
);
final res = await fuseSDK.stakeToken(
StakeRequestBody(
accountAddress: fuseSDK.wallet.getSender(),
tokenAmount: '0.1',
tokenAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE', // Native Token Address
),
);
print('UserOpHash: ${res.userOpHash}');
print('Waiting for transaction...');
final ev = await res.wait();
print('Transaction hash: ${ev?.transactionHash}');
Unstake
- Web
- Flutter
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}`
);
final res = await fuseSDK.unstakeToken(
UnstakeRequestBody(
accountAddress: fuseSDK.wallet.getSender(),
tokenAmount: '0.1',
tokenAddress: 'TOKEN_ADDRESS', // "0x34Ef2Cc892a88415e9f02b91BfA9c91fC0bE6bD4"
),
EthereumAddress.fromHex('0xb1DD0B683d9A56525cC096fbF5eec6E60FE79871'),
);
print('UserOpHash: ${res.userOpHash}');
print('Waiting for transaction...');
final ev = await res.wait();
print('Transaction hash: ${ev?.transactionHash}');