VIZ.cx
← Learn

Delegate SHARES

10 minintermediate

Delegation lets you lend capital without giving it away. The recipient gets the energy and voting power of your SHARES; you keep ownership and can pull it back anytime. It's how communities bootstrap newcomers — pair it with an invite and a new user can act immediately, funded by you.

Step 1 — Delegate SHARES

npm install @viz-cx/core

delegateVestingShares takes the delegatee and an amount in SHARES. The delegator is implicit.

import { createClient } from '@viz-cx/core'

const client = createClient({
  account: 'alice',
  activeKey: process.env.VIZ_ACTIVE_KEY!,
  endpoint: 'https://node.viz.cx',
})

// Lend capital to 'bob'. 'delegator' is implicit (the client's account).
// Bob gains the energy and voting power of these SHARES without owning them.
const result = await client.delegateVestingShares({
  delegatee: 'bob',
  vestingShares: '500.000000 SHARES',  // 6 decimals
})
console.log('Delegated:', result.id)

Step 2 — Adjust or revoke

The amount is the new total, not an increment — re-send with a higher or lower value to change it, or 0.000000 SHARES to revoke. Reclaimed capital returns to you after a short cooldown, then can be powered down again.

// Delegation is a target, not a delta. Set the NEW total to change it.
// Raise it:
await client.delegateVestingShares({ delegatee: 'bob', vestingShares: '800.000000 SHARES' })

// Lower it (or set 0 to revoke entirely):
await client.delegateVestingShares({ delegatee: 'bob', vestingShares: '0.000000 SHARES' })

Step 3 — See what's delegated

received_vesting_shares is capital borrowed in; delegated_vesting_shares is capital lent out. Effective power is own + received − delegated.

// Delegations are visible on the account. Reading Bob shows what he
// borrowed; reading Alice shows what she lent out.
const [bob] = await client.api.getAccounts(['bob'])
console.log('received:', bob.received_vesting_shares)   // borrowed in
console.log('own:     ', bob.vesting_shares)            // owned outright

Delegated capital can't be powered down until it's returned — so keep a buffer of undelegated SHARES if you may need to unstake.