Plug and Play Contracts

Ethereum Asked by Daniel Silveira on October 24, 2020

can any Ethereum Dev answer if there’s a ERC or even an EIP to define a way in which you can have a Smart Contract to be plug-and-play’d into another Smart Contract? I’m trying to come up with something, but don’t want to reinvent the wheel here.

To be more clear, what I’m planning to do is to create a dynamic and mutable mapping of address(SC)/functions/parameters allowing any function of any SC to be called from the one who implements this standard, thus, plug and play.

One Answer

It seems like you are trying to build a library. See here: Solidity > Libraries.

Libraries are similar to contracts, but their purpose is that they are deployed only once at a specific address and their code is reused using the DELEGATECALL (CALLCODE until Homestead) feature of the EVM. This means that if library functions are called, their code is executed in the context of the calling contract, i.e. this points to the calling contract, and especially the storage from the calling contract can be accessed.

Otherwise you might be thinking about inheritance: Solidity > Inheritance

When a contract inherits from multiple contracts, only a single contract is created on the blockchain, and the code from all the base contracts is copied into the created contract.

Let me know if this helps.

Answered by Shawn Tabrizi on October 24, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP