So I trying out the Mix IDE (1.03), and looking at the .html file from the sample project, there is a "contracts" global. Where is it defined?

function get() {
  var param = document.getElementById('query').value;
  var res = contracts['Sample'].contract.get();
  document.getElementById('queryres').innerText = res;

function set() {
  var key = document.getElementById('key').value;
  var res = contracts['Sample'].contract.set(key);
  • do you want to see where its defined? :)
    – niksmac
    May 7, 2016 at 15:49
  • Yes, thank you, I edited the question. Yes I would like to know where it's defined. May 7, 2016 at 19:19

2 Answers 2


Mix automatically generates the contracts array for you. You can manually create contract objects with code like the following:

var MyContract = web3.eth.contract(abiArray);

// instantiate by address
var contractInstance = MyContract.at([address]);

// deploy new contract
var contractInstance = MyContract.new([contructorParam1] [, contructorParam2], {data: '0x12345...', from: myAccount, gas: 1000000});

// Get the data to deploy the contract manually
var contractData = MyContract.new.getData([contructorParam1] [, contructorParam2], {data: '0x12345...'});
// contractData = '0x12345643213456000000000023434234'



"contracts" is inserted by Mix, you cannot change it. is there a specific reason why you need to access to the declaration?

  • Just curiosity. And maybe to replicate this abstraction to use in other IDEs, as it seems pretty convenient. Also, how do you publish your app to the real world? Is there a build option that generates the contracts declaration for you? May 11, 2016 at 22:37
  • to publish the dapp there is an option: "Deploy -> Deploy to network". There's also an option there to package the dapp
    – Yann
    May 12, 2016 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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