Skip to content

Commit 163cac2

Browse files
committed
chore: build message sample script
TICKET: COIN-4593
1 parent 7eaf1bf commit 163cac2

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

examples/ts/build-message.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Pre-build a message from the wallet
3+
*
4+
* This tool will help you see how to use the BitGo API to easily build
5+
* a message from a wallet.
6+
*
7+
* Copyright 2025, BitGo, Inc. All Rights Reserved.
8+
*/
9+
10+
import {BitGoAPI} from '@bitgo/sdk-api';
11+
import {Hteth} from "@bitgo/sdk-coin-eth";
12+
import {MessageStandardType} from "@bitgo/sdk-core"; // Replace with your given coin (e.g. Ltc, Tltc)
13+
require('dotenv').config({ path: '../../.env' });
14+
15+
const bitgo = new BitGoAPI({
16+
accessToken: process.env.TESTNET_ACCESS_TOKEN,
17+
env: 'test', // Change this to env: 'production' when you are ready for production
18+
});
19+
20+
// Set the coin name to match the blockchain and network
21+
// doge = dogecoin, tdoge = testnet dogecoin
22+
const coin = 'hteth';
23+
bitgo.register(coin, Hteth.createInstance);
24+
25+
const id = '';
26+
27+
async function main() {
28+
const wallet = await bitgo.coin(coin).wallets().get({ id });
29+
console.log(`Wallet label: ${wallet.label()}`);
30+
31+
const txRequest = await wallet.createSignMessageRequest({
32+
messageRaw: 'Hello, BitGo!',
33+
messageStandardType: MessageStandardType.EIP191,
34+
});
35+
console.dir(txRequest);
36+
}
37+
38+
main().catch((e) => console.log(e));

0 commit comments

Comments
 (0)