Interact with a deployed contract
You already have a contract address on Lumia and want to call it, either from code or from the explorer UI.
Who this is for: developers with a contract already deployed on Lumia mainnet or Beam testnet (see /build/quickstart or /build/smart-contracts/deploy-with-hardhat if you don't have one yet). Prerequisites: a deployed contract address and its ABI; network values from /reference/networks. Time: 10-15 minutes.
Steps
Open the contract address on the relevant explorer: mainnet
explorer.lumia.orgor Beambeam-explorer.lumia.org(see/reference/networksfor both).If the contract is verified, the explorer's Contract tab exposes Read Contract and Write Contract sub-tabs generated from the ABI. Unverified contracts only expose raw calldata entry. Verify first with
/build/smart-contracts/verify-with-hardhator/build/smart-contracts/verify-with-truffleif you need the decoded UI.Read Contract: expand a
view/purefunction, fill in arguments, click query. No wallet or gas needed.Write Contract: connect a wallet (must be on the same network as the contract), expand the function, fill in arguments, submit. This costs gas in the native token.
npm install ethersconst { ethers } = require("ethers");
// Use the RPC value for the network your contract is on; see /reference/networks.
// Do not retype it from memory; the retired "Lumia Testnet" RPC (chain ID 1952959480) is dead.
const provider = new ethers.JsonRpcProvider("https://beam-rpc.lumia.org");
const abi = [ /* your contract's ABI */ ];
const address = "0xYourContractAddress";
async function main() {
const contract = new ethers.Contract(address, abi, provider);
const value = await contract.someViewFunction();
console.log("Result:", value);
}
main();To send a state-changing transaction, attach a signer instead of a bare provider:
const { ethers } = require("ethers");
const provider = new ethers.JsonRpcProvider("https://beam-rpc.lumia.org");
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider); // testnet key only
const abi = [ /* your contract's ABI */ ];
const contract = new ethers.Contract("0xYourContractAddress", abi, wallet);
async function main() {
const tx = await contract.someStateChangingFunction(/* args */);
const receipt = await tx.wait();
console.log("Confirmed in block:", receipt.blockNumber);
}
main();The web3.js equivalent (new Web3(rpcUrl), new web3.eth.Contract(abi, address)) follows the same shape: provider/RPC URL, ABI, address, then .methods.fn().call() for reads or .send({ from }) for writes.
Verify it worked
A read call returns a decoded value with no error.
A write call's
tx.wait()(or the explorer's pending-tx banner) resolves to a receipt; open the transaction hash on the explorer and confirm status is Success.
Troubleshooting
Was this helpful?