1

I recently played a bit with solidity, creating some tokens, working with functions and so on.

Until now i only published the contracts via https://ethereum.github.io/browser-solidity/.

But how does it work if i want to add more contracts, related to a token? Specific functions, sales, etc.

Is there a function within the compiler where i can connect contracts - or do i have to host them somewhere together in a folder?

Thank yaa

| improve this question | | | | |
1

Each contract should be deployed independently to whatever the network you want. Each contract has its own unique address and that is what you use to access that contract from another contract or a dapp. You could find more details in following article. https://medium.com/@chim/ethereum-smart-contracts-lifecycle-multiple-contracts-message-sender-e9195ceff3ec?source=messageShare-8a2f5a39545b-1516585976

And a sample project below.

https://github.com/fidenz-chim/multiple_contract_test

| improve this answer | | | | |
  • Hey man, +10 for the article! What i dont understand completely, is: i saw that you linked the contract to each other, using import "./Deduct.sol";. But this relates to a folder structure. If i publish via the mentioned tool, how to get a connection to other contracts? Or do i then import with the contract address hex? – Peterx20 Jan 22 '18 at 8:16
  • Import helps to compile the contracts correctly. Once it is deployed to the EVM, you need only the contract byte code and its address. If you are familiar with DLLs in Windows environment (in a C/C++ context), you could think of this as an include/import of a .h of DLL/lib external to the application. .h file has nothing to do with the runtime but enables the source to compile & build to binary. – Chim Jan 22 '18 at 8:49
  • If you use remix to deploy your contracts, you would see, even though the contracts are interdependent, you could deploy each contract independently. Which confirms, all contracts are at the same level within EVM irrespective to dependencies while they are in execution. – Chim Jan 22 '18 at 8:51

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.