Send Single Transaction
Send single transaction
Transactions are cryptographically signed instructions from accounts. An account will initiate a transaction to update the state of the Fuse network. The simplest transaction is transferring Fuse Tokens from one account to another. To carry out a transaction using the FuseBox JS SDK, the callContract() method is used.
The callContract() method takes in 3 arguments: to, value and data.
callContract(to, value, data);
| Param | Type | Status | Description | 
|---|---|---|---|
| to | address | required | The address where the user want to send Tokens. | 
| value | number | required | The amount of Tokens the user is sending | 
| data | Function | Encoded Function Data for Smart Contract Methods | 
Example: index.ts
import { ethers } from "ethers";
import { FuseSDK } from "@fuseio/fusebox-web-sdk";
const main = async () => {
  const credentials = new ethers.Wallet("PRIVATE_KEY");
  const apiKey = "API_KEY";
  const fuseSDK = await FuseSDK.init(apiKey, credentials);
  console.log(`Sender Address is ${fuseSDK.wallet.getSender()}`);
  const to = "0xb6e4fa6ff2873480590c68d9aa991e5bb14dbf03";
  const value = ethers.utils.parseEther("0.001");
  const data = Uint8Array.from([]);
  console.log(data);
  const res = await fuseSDK.callContract(to, value, data);
  console.log(`UserOpHash: ${res?.userOpHash}`);
  console.log("Waiting for transaction...");
  const receipt = await res?.wait();
  console.log("Transaction Hash:", receipt?.transactionHash);
};
main();