Yesterday I made this ERC20 contract (which is supposed to work under State rent when holders pay for storing their tokens): work: https://github.com/ledgerwatch/eth_state/blob/master/erc20/TokenContract.sol
As you can see in the code, Solidity provides create2
assembly function, but working with it is cumbersome. It would be much easier if there were 2 new features in Solidity:
-
new2
operator. Similar tonew
, but also acceptsalt
parameter, and usesCREARE
opcode. So in myFactory
I would have writtenHolder holder = new2(Holder, _owner)
without having to put the byte code of theHolder
contract inside the function - Function
create2_address
, which allows computing address ofCREATE2
contract. I would have used it twice, first inToken.getHolderContract
function:address payable holder_address = create2_address(factory, a, Holder)
, and second inHolder.setOwner
function:require(create2_address(factor, _owner, Holder) == address(this))
It would be great to have (at least in a branch) a version of Solidity (derived from the current) supporting these two things. That would make further development of contracts like that much easier.
EDIT: Also linked this to: https://github.com/ethereum/solidity/issues/2136