-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
53 lines (42 loc) · 1.2 KB
/
index.js
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
45
46
47
48
49
50
51
52
53
import * as RPChCrypto from "@rpch/crypto";
import SDK from "@rpch/sdk";
import { ethers } from "ethers";
const sdk = new SDK(
{
crypto: RPChCrypto,
client: "your_client_name",
timeout: 20000,
discoveryPlatformApiEndpoint: "https://staging.discovery.rpch.tech",
},
setKeyValFunction,
getKeyValFunction
);
async function setKeyVal(key: string, val: string): Promise<void> {
localStorage.setItem(key, val);
}
async function getKeyVal(key: string): Promise<string | undefined> {
return localStorage.getItem(key);
}
async function sendTransaction() {
await sdk.start();
const providerUrl = 'https://primary.gnosis-chain.rpc.hoprtech.net';
const provider = new ethers.providers.JsonRpcProvider(providerUrl, {
RPCh: {
provider: sdk,
},
});
const privateKey = 'your_private_key_here';
const wallet = new ethers.Wallet(privateKey, provider);
const tx = {
to: '0x...',
value: ethers.utils.parseEther('1'),
};
const signedTx = await wallet.signTransaction(tx);
const txResponse = await sdk.sendRequest({
provider: 'eth_sendRawTransaction',
body: signedTx,
});
console.log('Transaction sent:', txResponse);
await sdk.stop();
}
sendTransaction();