Search⌘ K

Displaying the Deployed Contract Address

Explore how to capture and display the deployed smart contract address inside your Web3 app after deployment using Solidity and React. Learn to manage state to show contract details dynamically, validate partner addresses, and ensure users can interact with the contract's withdraw function securely.

We'll cover the following...

Showing the partnership address

The users can find the partnership contract address by looking at the Etherscan website. However, this is not the best user experience. We can show the partnership contract address after the deployment from inside our app. First, we’ll create a new state variable called deployedContractAddress:

const [deployedContractAddress, setDeployedContractAddress,] = useState("");

We’ll then update this state with the address data from the deployment receipt:

Node.js
on("receipt", (receipt) => {
// receipt will contain deployed contract address
console.log(receipt);
setIsDeploying(false);
setDeployedContractAddress(
receipt.contractAddress
);
});

If the ...