| 1234567891011121314151617181920212223242526272829303132 |
- package main
- import (
- "context"
- "log"
- "github.com/ethereum/go-ethereum"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/ethclient"
- )
- func main() {
- client, _ := ethclient.Dial("http://127.0.0.1:8545")
- defer client.Close()
- contractAddr := common.HexToAddress("0x8a9009847570fdbcc676c7fd547ab26a358a5005")
- myAddress := common.HexToAddress("0x10464a0e69e5bbd01b9bdb7f2943a103a885ff29")
- callMsg := ethereum.CallMsg{
- To: &contractAddr,
- From: myAddress,
- Data: common.FromHex("0x"),
-
- }
- res, err := client.CallContract(context.Background(), callMsg, nil)
- if err != nil {
- log.Fatalf("Error calling contract: %v", err)
- }
- log.Printf(common.BytesToAddress(res).Hex())
- }
|