Skip to content
On this page

Delegate Polygon

The delegate namespace contains methods used for sending transactions on delegation. The unique methods to the delegate namespace are:

  • approve(address, amount): Approval of the amount for further debiting by a smart contract.
  • delegate(address, amount): Delegate user tokens.

Delegate Code Example

ts
// Import SDK
import { Polygon } from '@everstake/wallet-sdk';

const address = '2f92e...6761b'

// The amount that the user delegates.
const amountDelegate = 10; // min value 1 (MATIC)

// Step 1 - Approve - if it is already approved returns 'approve' or transaction
const approve = await Polygon.approve(address, amountDelegate);
console.log(approve); // { result: 'approve' } or Raw Transaction

// Step 2 - Delegate - return Raw Transaction
const delegate = await Polygon.delegate(address, amountDelegate);
console.log(delegate); // Raw Transaction Object