Skip to content

Commit 3968b6a

Browse files
committed
docs(sdk-coin-xrp): added payment example
Ticket: COIN-6546
1 parent 2e80147 commit 3968b6a

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

examples/ts/xrp/send-payment.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Send a transaction from a TSS wallet at BitGo.
3+
*
4+
* Copyright 2023, BitGo, Inc. All Rights Reserved.
5+
*/
6+
import { BitGo } from 'bitgo';
7+
8+
async function sendTx() {
9+
const coin = 'txrp';
10+
11+
// TODO: set env to 'test' or 'prod'
12+
const env = 'test';
13+
14+
// TODO: set your access token here
15+
// You can get this from User Settings > Developer Options > Add Access Token
16+
const accessToken = '';
17+
18+
// TODO: set your wallet id
19+
const walletId = '';
20+
21+
// TODO: set your wallet passphrase
22+
const walletPassphrase = '';
23+
24+
// TODO: set the receive address to send fund(add destination tag)
25+
const receiveAddress = '';
26+
27+
const bitgo = new BitGo({
28+
env: env,
29+
accessToken,
30+
});
31+
32+
const basecoin = bitgo.coin(coin);
33+
bitgo.authenticateWithAccessToken({ accessToken });
34+
// await bitgo.unlock({ otp: otp, duration: 3600 });
35+
36+
const walletInstance = await basecoin.wallets().get({ id: walletId });
37+
const xrpAmount = '1222500'; // 1.2225 XRP
38+
const sendDetail = await walletInstance.sendMany({
39+
recipients: [
40+
{
41+
amount: xrpAmount,
42+
address: receiveAddress,
43+
},
44+
],
45+
walletPassphrase,
46+
type: 'payment',
47+
isTss: true,
48+
});
49+
console.log(`${JSON.stringify(sendDetail)}`);
50+
}
51+
52+
sendTx().catch((e) => console.error(e));

0 commit comments

Comments
 (0)