-
Notifications
You must be signed in to change notification settings - Fork 6
/
create-workflow.ts
44 lines (35 loc) · 1.49 KB
/
create-workflow.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
32
33
34
35
36
37
38
39
40
41
42
43
44
import { StakingClient } from '../../src/client/staking-client';
import { Workflow } from '../../src/gen/coinbase/staking/orchestration/v1/workflow.pb';
const walletAddress: string = '9NL2SkpcsdyZwsG8NmHGNra4i4NSyKbJTVd9fUQ7kJHR'; // replace with your wallet address
const amount: string = '100000000'; // replace with your amount. For solana it should be >= 0.1 SOL
const network: string = 'mainnet'; // replace with your network
// Set your api key name and private key here. Get your keys from here: https://portal.cdp.coinbase.com/access/api
const apiKeyName: string = 'your-api-key-name';
const apiPrivateKey: string = 'your-api-private-key';
const client = new StakingClient(apiKeyName, apiPrivateKey);
async function stakeSolana(): Promise<void> {
if (walletAddress === '') {
throw new Error('Please set the walletAddress variable in this file');
}
let workflow: Workflow = {} as Workflow;
try {
// Create a new solana stake workflow
workflow = await client.Solana.stake(network, walletAddress, amount);
console.log(JSON.stringify(workflow, null, 2));
} catch (error) {
let errorMessage = '';
if (error instanceof Error) {
errorMessage = error.message;
}
throw new Error(`Error creating workflow: ${errorMessage}`);
}
}
stakeSolana()
.then(() => {
console.log('Done creating sol staking workflow');
})
.catch((error) => {
if (error instanceof Error) {
console.error('Error creating sol staking workflow: ', error.message);
}
});