-
Notifications
You must be signed in to change notification settings - Fork 118
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
952fb72
commit 18d5a64
Showing
13 changed files
with
179 additions
and
43 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
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,8 @@ | ||
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.21 | ||
|
||
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 | ||
) |
File renamed without changes.
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,79 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"math/big" | ||
"os" | ||
|
||
"github.com/NethermindEth/juno/core/felt" | ||
"github.com/NethermindEth/starknet.go/rpc" | ||
"github.com/NethermindEth/starknet.go/utils" | ||
ethrpc "github.com/ethereum/go-ethereum/rpc" | ||
"github.com/joho/godotenv" | ||
) | ||
|
||
var ( | ||
name string = "integration" | ||
someMainnetContract string = "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d" // STRK | ||
contractMethod string = "balanceOf" | ||
) | ||
|
||
// main entry point of the program. | ||
// | ||
// It initializes the environment and establishes a connection with the client. | ||
// It then makes a contract call and prints the response. | ||
// | ||
// Parameters: | ||
// | ||
// none | ||
// | ||
// Returns: | ||
// | ||
// none | ||
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) | ||
} | ||
|
||
// 0x043784df59268c02b716e20bf77797bd96c68c2f100b2a634e448c35e3ad363e | ||
// 0x39180766dd93d979cd03e6ba93d3210fb7b7e56e01020942157e387a3613040 // Takes a good 10min to bridge.. | ||
// 0xffbc2e41bad21b80eea2590c38287718aced9db4c66ae693b5ed24320f6de7 | ||
// 0xc6e9dddcab4b464f2edc1cb4ef14163317a58ae64fd24ffe280baaf8eb5691 | ||
|
||
// 0x13d46bc231a47e29ee1e3c7fab338e6b13c935e002f2be57f7318e88cbb872e | ||
// 0x397ffc31dde066cab3f4a9f6315f5641620b2ee0622c042b91ade554ca4bff5 | ||
// 0x1fee7cfefa90a2878826212bb46bccddfb2473f306b7b17e4791bd0a486d4c6 | ||
// | ||
myAddr, _ := new(felt.Felt).SetString("0x043784df59268c02b716e20bf77797bd96c68c2f100b2a634e448c35e3ad363e") | ||
|
||
// Make read contract call | ||
tx := rpc.FunctionCall{ | ||
ContractAddress: contractAddress, | ||
EntryPointSelector: utils.GetSelectorFromNameFelt(contractMethod), | ||
Calldata: []*felt.Felt{myAddr}, | ||
} | ||
|
||
fmt.Println("Making Call() request", myAddr) | ||
callResp, err := clientv02.Call(context.Background(), tx, rpc.BlockID{Tag: "latest"}) | ||
if err != nil { | ||
fmt.Println("+--=-") | ||
panic(err.Error()) | ||
} | ||
qwe := new(big.Int) | ||
callResp[0].BigInt(qwe) | ||
fmt.Println(qwe) | ||
fmt.Println(fmt.Sprintf("Response to %s():%s ", contractMethod, callResp[0])) | ||
} |
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 was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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.21 | ||
|
||
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