-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4cfd1c
commit 7901da4
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# use this variable to change the RPC base URL | ||
#INTEGRATION_BASE=http_insert_end_point |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module account | ||
|
||
go 1.18 | ||
|
||
require github.com/NethermindEth/starknet.go v0.2.1-0.20220620163912-1db2ca279608 | ||
replace github.com/NethermindEth/starknet.go => ../../ | ||
require ( | ||
github.com/google/go-querystring v1.1.0 // indirect | ||
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect | ||
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
go 1.18 | ||
|
||
use ( | ||
. | ||
../.. | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/NethermindEth/starknet.go/rpcv02" | ||
"github.com/NethermindEth/starknet.go/types" | ||
"github.com/NethermindEth/starknet.go/utils" | ||
ethrpc "github.com/ethereum/go-ethereum/rpc" | ||
"github.com/joho/godotenv" | ||
) | ||
|
||
var ( | ||
name string = "mainnet" | ||
someMainnetContract string = "0x024dE48Fb640DB135B3dc85ef0FE2789e032FbCA2fca54E58aB8dB93ca22F767" | ||
contractMethod string = "getName" | ||
) | ||
|
||
func main() { | ||
fmt.Println("Starting simpeCall example") | ||
godotenv.Load(fmt.Sprintf(".env.%s", name)) | ||
base := os.Getenv("INTEGRATION_BASE") | ||
c, err := ethrpc.DialContext(context.Background(), base) | ||
if err != nil { | ||
panic(err) | ||
} | ||
clientv02 := rpcv02.NewProvider(c) | ||
fmt.Println("Established connection with the client") | ||
|
||
contractAddress, err := utils.HexToFelt(someMainnetContract) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Make read contract call | ||
tx := rpcv02.FunctionCall{ | ||
ContractAddress: contractAddress, | ||
EntryPointSelector: types.GetSelectorFromNameFelt(contractMethod), | ||
} | ||
|
||
fmt.Println("Making Call() request") | ||
callResp, err := clientv02.Call(context.Background(), tx, rpcv02.BlockID{Tag: "latest"}) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
|
||
fmt.Println(fmt.Sprintf("Response to %s():%s ", contractMethod, callResp[0])) | ||
} |