Send
The Sender
class from @holdstation/worldchain-sdk
allows developers to send native tokens (e.g., ETH) or ERC20 tokens on WorldChain easily.
Installation
Setup
Send Token
π Parameters
to
string
β Yes
Recipient wallet address.
amount
number
β Yes
Amount to send (expressed in normal units, not wei).
token
string
β Optional
ERC20 token contract address. If omitted, sends native token (e.g., ETH).
βΉοΈ Notes:
If
token
is omitted, the SDK will send native tokens like ETH.If
token
is provided, the SDK will send ERC20 tokens.amount
should be entered as a human-readable number (e.g.,0.1
ETH,10
Tokens).The conversion to correct base units is handled internally.
π Usage Examples
πΉ Send Native Token (e.g., ETH)
πΉ Send ERC20 Token
β οΈ Typical Error Cases
insufficient funds
Wallet does not have enough native token to pay for gas or the transfer amount.
Ensure the sender wallet has enough native balance (e.g., ETH) to cover both gas fee and transfer amount.
insufficient allowance
Trying to send ERC20 token but no prior approve() call made or allowance is too small.
Make sure the sender has granted sufficient allowance to the token contract via approve()
beforehand.
invalid address
The to
address or token
address is incorrectly formatted.
Verify that all addresses are valid Ethereum addresses (start with 0x
and 42 characters long).
transaction underpriced
Gas fee settings are too low.
Retry with higher gas price or gas limit depending on network congestion.
execution reverted
Smart contract rejected the transfer (e.g., paused token, blocked address).
Check token smart contract status and address restrictions.
Last updated