1

Blockchains supporting smart contract are sometimes compared with smartphones in the sense that it is an infrastructure opened to host an indefinite number of Apps, any participant can create and deploy to make it available to the entire network.

In the case of a private blockchain, the administrating party might not wish to allow the participants to deploy new contract but only to call the methods of the smart contract it had deployed.

Is there a way to branch Etherum code to allow that? If so, can the account(s) allowed for contract deployment be in the genesis block rather than hardcoded?

0

This is very easy to do by modifying the sources

In the file core/state_transition.go modify these lines:

if contractCreation {
    ret, _, st.gas, vmerr = evm.Create(sender, st.data, st.gas, st.value)
} else {
    // Increment the nonce for the next transaction
    st.state.SetNonce(sender.Address(), st.state.GetNonce(sender.Address())+1)
    ret, st.gas, vmerr = evm.Call(sender, st.to().Address(), st.data, st.gas, st.value)
}

by something like this:

if contractCreation {
    if sender.Bytes().Cmp(your_allowed_address_here.Bytes())==0 {
        ret, _, st.gas, vmerr = evm.Create(sender, st.data, st.gas, st.value)
    }
} else {
    // Increment the nonce for the next transaction
    st.state.SetNonce(sender.Address(), st.state.GetNonce(sender.Address())+1)
    ret, st.gas, vmerr = evm.Call(sender, st.to().Address(), st.data, st.gas, st.value)
}

where sender is the address executing the transaction, and your_allowed_address_here is the address that is the only one that can create contracts

I did not test the code above, but you have an idea.

1

Yes. If you're ready to branch and change the code, you can do anything you want. In this case you would "only" need to limit sender addresses allowed to send a transaction to address 0x0 (contract creation). You could make this configurable via genesis file, or if you're using PoA, you could allow this feature only for the network authorities. It is also possible to deploy a fixed number of contracts at genesis-time and disable creation of new contracts at all.

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.