forked from Switcheo/carbon-js-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delegate_tokens.ts
31 lines (26 loc) · 946 Bytes
/
delegate_tokens.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import BigNumber from "bignumber.js";
import * as BIP39 from "bip39";
import { CarbonSDK } from "./_sdk";
import "./_setup";
(async () => {
const mnemonics = process.env.MNEMONICS ?? BIP39.generateMnemonic();
console.log("mnemonics", mnemonics);
const sdk = await CarbonSDK.instance({
network: CarbonSDK.Network.LocalHost,
config: {
tmRpcUrl: process.env.TRPC_ENDPOINT,
},
});
const connectedSDK = await sdk.connectWithMnemonic(mnemonics);
console.log("connected sdk");
const result = await connectedSDK.query.staking.Validators({
status: ""
});
console.log("validators", result);
const validator = result.validators[0];
const delegationResult = await connectedSDK.staking.delegateTokens({
validatorAddress: validator.operatorAddress,
amount: new BigNumber("100000000"),
})
console.log("delegationResult", delegationResult);
})().catch(console.error).finally(() => process.exit(0));