txn3
v0.0.0
Published
Transaction Builder for Web3
Downloads
0
Readme
txn3
Transaction Builder for Web3
Installation
$ npm install txn3Usage
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) => TransactionParameters
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) => TransactionParameters
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) => TransactionParameters
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) => TransactionBridge
Signature
bridge(params: BridgeParams) => TransactionStake
Signature
stake(params: StakeParams) => TransactionSupply
Signature
supply(params: SupplyParams) => TransactionBorrow
Signature
borrow(params: BorrowParams) => TransactionTypes
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;
}