Web3 API Reference
web3.eth
The web3-eth package allows you to interact with the WorldLand blockchain and smart contracts.
javascript
var Eth = require('web3-eth');
// Connect to WorldLand Seoul Mainnet
var eth = new Eth('https://seoul.worldland.foundation/');
// or using the web3 umbrella package
var Web3 = require('web3');
var web3 = new Web3('https://seoul.worldland.foundation/');
// -> web3.ethCommonly Used Methods
Block & Network
| Method | Description |
|---|---|
web3.eth.getBlockNumber() | Returns the current block number |
web3.eth.getBlock(blockNumber) | Returns a block matching the block number |
web3.eth.getChainId() | Returns the chain ID (103 for Seoul) |
web3.eth.isSyncing() | Returns sync status of the node |
web3.eth.getGasPrice() | Returns the current gas price |
web3.eth.getProtocolVersion() | Returns the protocol version |
web3.eth.getCoinbase() | Returns the coinbase address |
web3.eth.isMining() | Returns whether the node is mining |
web3.eth.getHashrate() | Returns the current hashrate |
Account & Balance
| Method | Description |
|---|---|
web3.eth.getAccounts() | Returns list of accounts |
web3.eth.getBalance(address) | Returns the balance of an address |
web3.eth.getTransactionCount(address) | Returns the nonce of an address |
web3.eth.requestAccounts() | Request accounts from the provider |
Transaction
| Method | Description |
|---|---|
web3.eth.sendTransaction(txObject) | Sends a transaction |
web3.eth.sendSignedTransaction(signedTx) | Sends a signed transaction |
web3.eth.getTransaction(txHash) | Returns a transaction by hash |
web3.eth.getTransactionReceipt(txHash) | Returns a transaction receipt |
web3.eth.getPendingTransactions() | Returns pending transactions |
web3.eth.getTransactionFromBlock(block, index) | Returns transaction by block |
web3.eth.signTransaction(txObject) | Signs a transaction |
web3.eth.sign(address, data) | Signs data |
web3.eth.call(callObject) | Executes a message call |
web3.eth.estimateGas(callObject) | Estimates gas for a transaction |
Contract & Storage
| Method | Description |
|---|---|
web3.eth.getCode(address) | Returns the code at an address |
web3.eth.getStorageAt(address, position) | Returns the storage at a position |
web3.eth.getPastLogs(options) | Returns past logs matching filter |
web3.eth.getProof(address, keys, block) | Returns the account proof |
Mining
| Method | Description |
|---|---|
web3.eth.getWork() | Returns the current mining work |
web3.eth.submitWork(nonce, header, digest) | Submits a proof-of-work solution |
Additional Modules
| Module | Description |
|---|---|
web3.eth.subscribe | Subscribe to blockchain events (WebSocket only) |
web3.eth.Contract | Interact with smart contracts |
web3.eth.Iban | IBAN address conversion |
web3.eth.personal | Account management functions |
web3.eth.accounts | Account creation and signing |
web3.eth.ens | Ethereum Name Service interaction |
web3.eth.abi | ABI encoding/decoding |
web3.eth.net | Network properties |
Provider Configuration
setProvider
javascript
web3.setProvider(new Web3.providers.HttpProvider('https://seoul.worldland.foundation/'));Default Settings
| Property | Description |
|---|---|
web3.eth.defaultAccount | Default address used as from |
web3.eth.defaultBlock | Default block (latest, pending, etc.) |
web3.eth.defaultHardfork | Default hardfork |
web3.eth.defaultChain | Default chain |
web3.eth.transactionBlockTimeout | Blocks to wait before timeout (default: 50) |
web3.eth.transactionConfirmationBlocks | Confirmations needed (default: 24) |
web3.eth.transactionPollingTimeout | Polling timeout in seconds |
web3.eth.handleRevert | Return revert reason on failure |
INFO
WorldLand supports the same JSON-RPC module as Ethereum. See the JSON-RPC APIs of Ethereum and go-ethereum for comprehensive details.