0

I've been teaching myself ethereum via the stack solidity/truffle/truffle-contract/testrpc/metamask. I built a small dApp that runs on testrpc with proper unit tests which work great. I've written a function that I truffle serve that loads my contract named VEX from the local the file f_deployed_contract

$.getJSON(f_deployed_contract, function(data) {
    App.contracts.VEX = TruffleContract(data);
    App.contracts.VEX.setProvider(App.web3Provider);
});

Everything works! I was excited, so I deployed the contract of the working solidity code using a combination of Remix and Ether Wallet to the mainnet. It was mined and now lives here:

https://etherscan.io/tx/0xe5e6c5d463815e339a2aac2e92594de595e2029e6448997799871d8cb2a5728b

Now, how do I adjust my TruffleContract so I can use my dApp with metamask on the mainnet?

1

Using TruffleContract, you can just specify the address of your contract when trying to interact with it. From the documenation:

var MetaCoin = require("./path/to/MetaCoin.sol.js");
MetaCoin.at(contract_address).then(function(instance) {
   //do promise things
} 

So, Instead of using Metacoin.deployed() , which you're probably using, , you could use .at(address).

Also, your contract lives at 0x4f5a4501f96cb95eeda376f4caa0b24f4dbbd796, not 0xe5e6c5d463815e339a2aac2e92594de595e2029e6448997799871d8cb2a5728b. The second one is the transaction which created your contract, the first one is the address of your contract.

  • That makes sense. So if I deploy multiple copies of the same contract (same bytecode but in different places), I can just call the different contracts by using .at(address) for each one? – Hooked Sep 12 '17 at 14:49
  • that would be correct – Qkyrie Sep 12 '17 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.