This repository has been archived by the owner on Aug 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add funccall Signed-off-by: Qiang Zhou <[email protected]> * add randata Signed-off-by: Qiang Zhou <[email protected]> * add invoke Signed-off-by: Qiang Zhou <[email protected]> * add invoke Signed-off-by: Qiang Zhou <[email protected]> * update cairo Signed-off-by: Qiang Zhou <[email protected]> * update felt Signed-off-by: Qiang Zhou <[email protected]> * update code Signed-off-by: Qiang Zhou <[email protected]> * update randata Signed-off-by: Qiang Zhou <[email protected]> * debug * change cool contract * clean * update contract * increase_value * upgrade starknet.go * spew.Dump * set_value --------- Signed-off-by: Qiang Zhou <[email protected]> Co-authored-by: Lawliet-Chan <[email protected]>
- Loading branch information
1 parent
d287179
commit 27d64f8
Showing
7 changed files
with
255 additions
and
1,360 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package cairoVM | ||
|
||
import ( | ||
"fmt" | ||
"github.com/NethermindEth/juno/core" | ||
"github.com/NethermindEth/juno/core/felt" | ||
"github.com/NethermindEth/starknet.go/account" | ||
"github.com/NethermindEth/starknet.go/rpc" | ||
"github.com/NethermindEth/starknet.go/utils" | ||
) | ||
|
||
var ( | ||
contractMethod string = "set_value" | ||
) | ||
|
||
func NewInvoke() (*core.InvokeTransaction, error) { | ||
//InvokeTx := rpc.InvokeTxnV1{ | ||
// Version: rpc.TransactionV1, | ||
// Type: rpc.TransactionType_Invoke, | ||
//} | ||
|
||
// Converting the contractAddress from hex to felt | ||
contractAddress := new(felt.Felt).SetUint64(2) | ||
|
||
params := new(felt.Felt).SetUint64(111) | ||
// Building the functionCall struct, where : | ||
FnCall := rpc.FunctionCall{ | ||
ContractAddress: contractAddress, //contractAddress is the contract that we want to call | ||
EntryPointSelector: utils.GetSelectorFromNameFelt(contractMethod), //this is the function that we want to call | ||
Calldata: []*felt.Felt{params}, //this is the data that we want to pass to the function | ||
} | ||
|
||
txCallData := account.FmtCallDataCairo2([]rpc.FunctionCall{FnCall}) | ||
|
||
fmt.Println("invoke calldata = ", txCallData) | ||
|
||
nonce := new(felt.Felt).SetUint64(1) | ||
tx := core.InvokeTransaction{ | ||
Nonce: nonce, | ||
MaxFee: &felt.Zero, | ||
Version: new(core.TransactionVersion).SetUint64(1), | ||
ContractAddress: contractAddress, | ||
EntryPointSelector: utils.GetSelectorFromNameFelt(contractMethod), | ||
CallData: txCallData, | ||
// CallData: []*felt.Felt{randata}, | ||
} | ||
|
||
return &tx, nil | ||
|
||
} |
Oops, something went wrong.