1

I want to create a private network, and allow anyone to deploy a contract via an RPC call.

Is it possible to allow someone to deploy a contract via a node that they do not own?

2

Yes. Nodes and transactions (deployment of a contract is just a transaction) are two completely separate things. If the node has an RPC interface opened and it allows you to send requests with a method named eth_sendrawtransaction, then you can forge your contract data and send it to the network through this node. No need to have your account key handled by the node and it's more secure. Creating the contract data is beyond the scope of this question but know that tools like remix ide or truffle can help.

Disclaimer: I work on Besu so I gave the method link pointing to it, but you can do the same with other clients.

| improve this answer | |
  • Thank you for your answer! This is another question, so it might be inappropriate to ask here, but I want to clear one point. Is it secure or should I be careful for something when allowing send trancation RPC call for anyone outside private network? – 久保圭司 Dec 26 '19 at 18:30
  • 2
    @engineerk You can keep the network private and still let anyone run a node. Running a node just gives you the ability to help keep the network honest. It doesn't give any ownership or control. If you don't let people run nodes, you have a huge problem -- how can anyone tell what the state of the network is? How can they know what contracts are deployed or what actions those contracts took? – David Schwartz Dec 26 '19 at 19:05
  • @DavidSchwartz Absolutely as you say! I mistakenly thought that private network of ethereum is like private network of Quorum which has no incentive mechanism and based on trust of nodes. More nodes are good for ethereum network to be more secure. Thanks. – 久保圭司 Dec 26 '19 at 19:29
  • 1
    Also note the difference between sendTrandaction RPC call and sendRawTransaction. The raw version takes an already signed tx and the other requires the node to have access to a signing mechanism. If your node has access to private keys to sign, it's strongly recommended NOT to let anyone access rpc on this node. But the real best practice is either not to use the node keys manager or to use a vault. You also have signing proxies available to remove the need for your node to have keys exposed. You can find this kind of tool on besu.hyperledger.org/en/stable/HowTo/Send-Transactions/Accou – Nicolas Massart Dec 26 '19 at 19:50
1

Contract deployment costs gas, so in order to deploy contract one usually has to have externally owner account with non-zero ether balance.

However, you may create backend that will accept contract deployment transaction from a user via RPC even if origin address of the transaction does not have any ether on balance. After accepting such transaction, the backend will just send some ether to the transaction's origin address right before publishing the transaction.

| improve this answer | |

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.