Using address of a contract

This method of creating a contract instance is used when a contract is already deployed and instantiated. This method of creating a contract uses the address of an existing, deployed contract. No new instance is created; rather, an existing instance is reused. A reference to the existing contract is made using its address.

In the next code illustration, two contracts, HelloWorld and client, are defined. In this scenario, one contract(client) uses an already known address of another contract to create a reference to it (HelloWorld). It does so using the address data type and casting the actual address to the HelloWorld contract type. The myObj object contains the address of an existing contract, as shown in the ...

Get Solidity Programming Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.