-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtransaction.js
39 lines (30 loc) · 1008 Bytes
/
transaction.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
import { Transaction, TransactionComputer } from "@multiversx/sdk-core";
import {
receiverAddress,
syncAndGetAccount,
senderAddress,
getSigner,
apiNetworkProvider,
} from "./setup.js";
const sendEgld = async () => {
const user = await syncAndGetAccount();
const transaction = new Transaction({
data: Buffer.from("This is the demo transaction!"),
gasLimit: 100000n,
sender: senderAddress,
receiver: receiverAddress,
value: 1000000000000000n, // 0.001 EGLD
chainID: "D",
});
transaction.nonce = user.getNonceThenIncrement();
const computer = new TransactionComputer();
const serializedTransaction = computer.computeBytesForSigning(transaction);
const signer = await getSigner();
transaction.signature = await signer.sign(serializedTransaction);
const txHash = await apiNetworkProvider.sendTransaction(transaction);
console.log(
"Check in the explorer: ",
`https://devnet-explorer.multiversx.com/transactions/${txHash}`
);
};
sendEgld();