miguelmota / ethereum-development-with-go-book

📖 A little guide book on Ethereum Development with Go (golang)

Home Page:https://goethereumbook.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

deploy contract and call a function in one go

huahuayu opened this issue · comments

hi Miguel,

Usually, the process is to deploy contact first and then call the function.

But now the cost for deploy a contract is high.

I wonder if I can deploy a contract and call a function within one transaction?

You may think why I want to do this because it's a special temporary contract, I just need to call the function once in mainnet , and what's more, I don't really need to submit it to chain, I just want to estimate gas for that function.

I get it, I can put that function call in the constructor, so it will be executed in deployment.

Yes that's the way to do it!