Example Usage
Remote Signing
The below example code displays the usage of customSigner to remotely sign a transaction that was generated by Anchor Earn.
For demonstration purposes, implementation of customSigner was done using Terra.js. For real usage customSigner should be connected with a remote signing solution used by the integrator (e.g. Ledger Hardware Wallet, Custodian APIs).
const anchorEarn = new AnchorEarn({
chain: CHAINS.TERRA,
network: NETWORKS.BOMBAY_12,
mnemonic:
'...',
});
// customSigner signs the generated unsigned tx
const customSigner = async (tx: Msg[]) => {
const account = new MnemonicKey({
mnemonic:
'...',
});
const wallet = new Wallet(
new LCDClient({
URL: 'https://bombay-lcd.terra.dev',
chainID: 'bombay-12',
}),
account,
);
return await wallet.createAndSignTx({
msgs: tx,
gasAdjustment: 2,
gasPrices: { uusd: 0.15 },
});
};
await anchorEarn.deposit({
amount: '0.01',
currency: DENOMS.UST,
log: (data) => {
console.log(data);
},
customSigner: customSigner,
});Remote Signing & Broadcasting
The below example code displays the usage of customBroadcaster to remotely sign and broadcast a transaction that was generated by Anchor Earn.
For demonstration purposes, implementation of customBroadcaster was done using Terra.js. For real usage customBroadcaster should be connected with a remote signing solution used by the integrator (e.g. Web Wallet Extension).
Logging Transaction Progress
The below example code displays the usage of loggable to check on request progresses that were generated by Anchor Earn.
Last updated
Was this helpful?