Skip to content

Instantly share code, notes, and snippets.

@huahuayu
Created August 25, 2018 04:20
Show Gist options
  • Save huahuayu/2f5704eb4330a23333fc07f8e761eef8 to your computer and use it in GitHub Desktop.
Save huahuayu/2f5704eb4330a23333fc07f8e761eef8 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
)
func main() {
// Create an IPC based RPC connection to a remote node
conn, err := ethclient.Dial("https://ropsten.infura.io/aikxiYGH1Yoq8PVbKNB6")
if err != nil {
log.Fatalf("Failed to connect to the Ethereum client: %v", err)
}
// Instantiate the contract and display its name
token, err := NewMTTToken(common.HexToAddress(" 0x466fb2e1979de417a30836a82c1739706938776a"), conn)
if err != nil {
log.Fatalf("Failed to instantiate a Token contract: %v", err)
}
name, err := token.Name(nil)
if err != nil {
log.Fatalf("Failed to retrieve token name: %v", err)
}
fmt.Println("Token name:", name)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment