Commit, Claim, & Compound APH

All operations related to commit, claim, and compound can be performed over NEO RPC by issuing contract transactions.

Commit

This example shows committing 10000 Aphelion.

const gasFee = 0.001;
executeContractTransaction('commit', [10000], 0, 0, gasFee);

Get Committed Balance

import { wallet } from '@cityofzion/neon-js';

async function getCommittedBalanceForAddress(address) {
  const addressScriptHash = wallet.getScriptHashFromAddress(address.replace('0x', ''));
  try {
    const res = await executeReadOnlyContractOperation('getContributed', [
      u.reverseHex(addressScriptHash.replace('0x', '')),
    ]);

    if (res.success && res.result.length >= 1) {
      return u.fixed82num(res.result);
    }
    return 0;
  } catch (e) {
    throw Error(`Failed to fetch contract balance. ${e}`);
  }
}

Claim

This example shows claiming all committed aphelion.

const gasFee = 0.001;
executeContractTransaction('claim', [], 0, 0, gasFee, true);

Compound

This example shows compounding earnings into the existing commitment.

const gasFee = 0.001;
executeContractTransaction('compound', [], 0, 0, gasFee);