Say you have a contract like the one below deployed at address 0x1f2deF1210B4D06B267A64b9888990734Aba7e24
pragma solidity ^0.8.1;
contract test {
string public initialString = "Hello World!";
function getString() public view returns (string memory) {
return initialString;
}
}
To create an instance of that contract:
truffle(develop)> contract = await test.at('0x1f2deF1210B4D06B267A64b9888990734Aba7e24')
To call a function:
truffle(develop)> a = await contract.getString()
To check the variable directly (if declared as public):
truffle(develop)> b = await.contract.initialString()
This way, you will have in a
and b
the expected values.
Of course you need to point to the right Ethereum network within the truffle-config.js
file in networks section.