deep-ink-ventures / genesis-dao-frontend

https://genesis-dao-frontend-zeta.vercel.app
Apache License 2.0
4 stars 5 forks source link

Allow people to withdraw from escrow #291

Open deep-ink-ventures opened 11 months ago

deep-ink-ventures commented 11 months ago

image

Total

// AccountId to check for total tokens
const account = '...'; // Replace with the actual AccountId

// Query total tokens
const totalTokens = await contract.query.getTotal(account, { gasLimit: -1 }, account);

if (totalTokens.result.isOk) {
  console.log(`Total tokens: ${totalTokens.output.toHuman()}`);
} else {
  console.error('Error fetching total tokens');
}

How many tokens are unvested:

// AccountId to check for unvested tokens
const account = '...'; // Replace with the actual AccountId

// Query unvested tokens
const unvestedTokens = await contract.query.getUnvested(account, { gasLimit: -1 }, account);

if (unvestedTokens.result.isOk) {
  console.log(`Unvested tokens: ${unvestedTokens.output.toHuman()}`);
} else {
  console.error('Error fetching unvested tokens');
}

How many tokens are available for withdraw

// AccountId to check for available withdrawal
const account = '...'; // Replace with the actual AccountId

// Query available tokens for withdrawal
const availableForWithdraw = await contract.query.getAvailableForWithdraw(account, { gasLimit: -1 }, account);

if (availableForWithdraw.result.isOk) {
  console.log(`Available for withdrawal: ${availableForWithdraw.output.toHuman()}`);
} else {
  console.error('Error fetching available tokens for withdrawal');
}

Withdraw:

// AccountId from which tokens will be withdrawn
const account = '...'; // Replace with the actual AccountId

// Withdraw vested tokens
await contract.tx.withdraw({ value, gasLimit }, account)
  .signAndSend(sender, (result) => {
    if (result.status.isInBlock) {
      console.log('Withdrawal in a block');
    } else if (result.status.isFinalized) {
      console.log('Withdrawal finalized');
    }
  });