diff --git a/examples/simpleInvoke/go.work b/examples/simpleInvoke/go.work new file mode 100644 index 00000000..b32bc53a --- /dev/null +++ b/examples/simpleInvoke/go.work @@ -0,0 +1,6 @@ +go 1.18 + +use ( + . + ../.. +) diff --git a/examples/simpleInvoke/main.go b/examples/simpleInvoke/main.go index 03fa8f3b..3520e4fd 100644 --- a/examples/simpleInvoke/main.go +++ b/examples/simpleInvoke/main.go @@ -34,24 +34,34 @@ func main() { panic(err) } clientv02 := rpc.NewProvider(c) - account_address, _ := utils.HexToFelt(account_addr) + account_address, err := utils.HexToFelt(account_addr) + if err != nil { + panic(err.Error()) + } ks := starknetgo.NewMemKeystore() fakePrivKeyBI, _ := new(big.Int).SetString(privateKey, 0) + ks.Put(public_key, fakePrivKeyBI) fmt.Println("Established connection with the client") - maxfee, _ := utils.HexToFelt("0x9184e72a000") + maxfee, err := utils.HexToFelt("0x9184e72a000") + if err != nil { + panic(err.Error()) + } InvokeTx := rpc.InvokeTxnV1{ MaxFee: maxfee, Version: rpc.TransactionV1, - Nonce: new(felt.Felt).SetUint64(104), // You will have to modify this accordingly + Nonce: new(felt.Felt).SetUint64(108), // You will have to modify this accordingly Type: rpc.TransactionType_Invoke, SenderAddress: account_address, } - contractAddress, _ := utils.HexToFelt(someContract) + contractAddress, err := utils.HexToFelt(someContract) + if err != nil { + panic(err.Error()) + } FnCall := rpc.FunctionCall{ ContractAddress: contractAddress, @@ -64,19 +74,11 @@ func main() { panic(err.Error()) } accnt.BuildInvokeTx(context.Background(), &InvokeTx, &[]rpc.FunctionCall{FnCall}) - txHash, err := accnt.TransactionHashInvoke(InvokeTx) - if err != nil { - panic(err.Error()) - } - fmt.Printf("TxHash :", txHash) + resp, err := accnt.AddInvokeTransaction(context.Background(), InvokeTx) if err != nil { panic(err.Error()) } - fmt.Printf("Response : ", resp) + fmt.Println("Response : ", resp) } - -// func main() { -// ExecuteIncreaseValue() -// }