txn3
v0.0.0
Published
Transaction Builder for Web3
Downloads
2
Readme
txn3
Transaction Builder for Web3
Installation
$ npm install txn3
Usage
import Txn3 from "txn3";
const txn3 = new Txn3({ ethereum: { sepolia: "https://rpc.sepolia.org" } });
Documentation
Methods
Send
Sends the native currency.
Signature
send(params: SendParams) => Transaction
Parameters
interface SendParams {
amount: string;
from: string;
to: string;
}
Example
txn3.ethereum("sepolia").send({
amount: "0.123",
from: "0x...",
to: "0x...",
});
Send an NFT
Signature
sendNft(params: SendNftParams) => Transaction
Parameters
interface SendNftParams {
amount: string;
contractAddress: string;
from: string;
to: string;
tokenId: string;
}
Example
txn3.ethereum("sepolia").sendNft({
amount: "0.123",
contractAddress: "0x...",
from: "0x...",
to: "0x...",
tokenId: "123",
});
Send a Token
Signature
sendToken(params: SendTokenParams) => Transaction
Parameters
interface SendTokenParams {
amount: string;
contractAddress: string;
from: string;
to: string;
}
Example
txn3.ethereum("sepolia").sendToken({
amount: "0.123",
contractAddress: "0x...",
from: "0x...",
to: "0x...",
});
Swap
Signature
swap(params: SwapParams) => Transaction
Bridge
Signature
bridge(params: BridgeParams) => Transaction
Stake
Signature
stake(params: StakeParams) => Transaction
Supply
Signature
supply(params: SupplyParams) => Transaction
Borrow
Signature
borrow(params: BorrowParams) => Transaction
Types
Transaction
interface Transaction {
from(serialized: string): Transaction;
serialize(): string;
}
SendParams
interface SendParams {
amount: string;
from: string;
to: string;
}
SendNftParams
interface SendNftParams {
amount: string;
contractAddress: string;
from: string;
to: string;
}
interface EthereumSendNftParams extends SendNftParams {
tokenId: string;
}
SendTokenParams
interface SendTokenParams {
amount: string;
contractAddress: string;
from: string;
to: string;
}