Created
August 25, 2018 04:20
-
-
Save huahuayu/2f5704eb4330a23333fc07f8e761eef8 to your computer and use it in GitHub Desktop.
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 ( | |
"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