-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into CreateDeployAcntExample
- Loading branch information
Showing
6 changed files
with
105 additions
and
17 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
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,9 @@ | ||
Note: To run this example, you need a mainnet endpoint. | ||
|
||
Steps to run this example on mainnet: | ||
1. rename ".env.template" to ".env.mainnet" | ||
2. uncomment, and set INTEGRATION_BASE to the mainnet url | ||
3. make sure you are in the "simpleCall" directory | ||
4. execute "go mod tidy" | ||
5. execute "go run main.go" | ||
|
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,35 @@ | ||
module account | ||
|
||
go 1.18 | ||
|
||
require ( | ||
github.com/NethermindEth/starknet.go v0.2.1-0.20220620163912-1db2ca279608 | ||
github.com/ethereum/go-ethereum v1.10.26 | ||
github.com/joho/godotenv v1.4.0 | ||
) | ||
|
||
replace github.com/NethermindEth/starknet.go => ../../ | ||
|
||
require ( | ||
github.com/NethermindEth/juno v0.3.1 // indirect | ||
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect | ||
github.com/bits-and-blooms/bitset v1.7.0 // indirect | ||
github.com/consensys/gnark-crypto v0.11.0 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/deckarep/golang-set v1.8.0 // indirect | ||
github.com/fxamacker/cbor/v2 v2.4.0 // indirect | ||
github.com/go-ole/go-ole v1.2.1 // indirect | ||
github.com/go-stack/stack v1.8.0 // indirect | ||
github.com/gorilla/websocket v1.4.2 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect | ||
github.com/stretchr/testify v1.8.1 // indirect | ||
github.com/test-go/testify v1.1.4 // indirect | ||
github.com/tklauser/go-sysconf v0.3.5 // indirect | ||
github.com/tklauser/numcpus v0.2.2 // indirect | ||
github.com/x448/float16 v0.8.4 // indirect | ||
golang.org/x/crypto v0.2.0 // indirect | ||
golang.org/x/sys v0.3.0 // indirect | ||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // 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,51 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/NethermindEth/starknet.go/rpc" | ||
"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 { | ||
fmt.Println("Failed to connect to the client, did you specify the url in the .env.mainnet?") | ||
panic(err) | ||
} | ||
clientv02 := rpc.NewProvider(c) | ||
fmt.Println("Established connection with the client") | ||
|
||
contractAddress, err := utils.HexToFelt(someMainnetContract) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Make read contract call | ||
tx := rpc.FunctionCall{ | ||
ContractAddress: contractAddress, | ||
EntryPointSelector: types.GetSelectorFromNameFelt(contractMethod), | ||
} | ||
|
||
fmt.Println("Making Call() request") | ||
callResp, err := clientv02.Call(context.Background(), tx, rpc.BlockID{Tag: "latest"}) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
|
||
fmt.Println(fmt.Sprintf("Response to %s():%s ", contractMethod, callResp[0])) | ||
} |