Now that we've deployed our contracts, let's check that the deployment initialized them as expected. To do this we'll call our deployed contracts directly, and to do this we'll use truffle console, which we can run with the following command:
truffle console --network rinkeby
At the prompt, we can then get a reference to our deployed token contract:
truffle(rinkeby)> PacktToken.deployed().then(function(instance) { tokenInstance = instance; })
undefined
And, from here, we can check our public state variables:
truffle(rinkeby)> tokenInstance.name()
'Packt ERC20 Token'
truffle(rinkeby)> tokenInstance.symbol()
'PET'
truffle(rinkeby)> tokenInstance.totalSupply().then(function(supply) { tokenSupply = supply; })
undefined
truffle(rinkeby)> tokenSupply.toNumber()
1000000
In the constructor of our token contract, we also assigned the total supply of tokens to the token creator. We deployed the contracts via the Geth client, so the contract owner is the account we created in the Geth console, which we can also read in Truffle's console:
truffle(rinkeby)> web3.eth.accounts
This will output the account that deployed the contracts, which we can then confirm was assigned the total supply in the constructor:
truffle(rinkeby)> tokenInstance.balanceOf("<your_account_address>").then(function(balance) { ownerBalance = balance; })
undefined
truffle(rinkeby)> ownerBalance.toNumber()
1000000