|
| 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