-
-
Save lightclient/668353c6ba0d85ce901edb7048bd1562 to your computer and use it in GitHub Desktop.
EIP-4788 deployer calculation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"math/big" | |
"github.com/ethereum/go-ethereum/common" | |
"github.com/ethereum/go-ethereum/core" | |
"github.com/ethereum/go-ethereum/core/types" | |
"github.com/ethereum/go-ethereum/crypto" | |
"github.com/ethereum/go-ethereum/params" | |
) | |
func main() { | |
data := common.Hex2Bytes("605a8060095f395ff33373fffffffffffffffffffffffffffffffffffffffe14604257602036146024575f5ffd5b620180005f350680545f351415603d576201800001545f525b60205ff35b42620180004206555f3562018000420662018000015500") | |
gas, err := core.IntrinsicGas(data, nil, true, true, true, true) | |
if err != nil { | |
fmt.Printf("err: %v\n", err) | |
return | |
} | |
tx := types.NewTx( | |
&types.DynamicFeeTx{ | |
ChainID: common.Big1, | |
Nonce: 0, | |
GasTipCap: newGwei(42), | |
GasFeeCap: newGwei(1000), | |
Gas: gas, | |
To: nil, | |
Value: common.Big0, | |
Data: data, | |
V: common.Big0, | |
R: big.NewInt(1337), | |
S: new(big.Int).SetBytes(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000001337")), | |
}) | |
buf, err := json.MarshalIndent(tx, " ", "") | |
if err != nil { | |
fmt.Printf("err: %v", err) | |
return | |
} | |
fmt.Println(string(buf)) | |
signer := types.LatestSignerForChainID(common.Big1) | |
addr, err := signer.Sender(tx) | |
if err != nil { | |
fmt.Printf("err: %v", err) | |
return | |
} | |
fmt.Println("addr", addr) | |
fmt.Println("deployed addr", crypto.CreateAddress(addr, 0)) | |
} | |
func newGwei(n int64) *big.Int { | |
return new(big.Int).Mul(big.NewInt(n), big.NewInt(params.GWei)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment