NethermindEth / starknet.go

Golang Library for StarkNet/Cairo
MIT License
143 stars 95 forks source link

Transfer fee estimate error #540

Closed KillerJi closed 3 months ago

KillerJi commented 3 months ago

Hi sir

I want to estimate the transfer cost. I added 2 parameters but got an error.

acc, err := new(felt.Felt).SetString(account_addr) if err != nil { panic(err.Error()) } transferNum, err := new(felt.Felt).SetString("100000000000") if err != nil { panic(err.Error()) } 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{acc, transferNum}, } // Build the Calldata InvokeTx.Calldata, err = accnt.FmtCalldata([]rpc.FunctionCall{FnCall}) if err != nil { panic(err.Error()) }

// Sign the transaction err = accnt.SignInvokeTransaction(context.Background(), &InvokeTx) if err != nil { panic(err.Error()) }

fmt.Println("Calling EstimateFee") resp, err := accnt.EstimateFee(context.Background(), []rpc.BroadcastTxn{InvokeTx}, []rpc.SimulationFlag{}, rpc.BlockID{Tag: "latest"}) if err != nil { panic(fmt.Sprintf("Failed to estimate fee: %v", err)) } I have tried many times but it still doesn’t work. This sender and received address is the example test address:0x06462ead89e36162065434c276ec043ecf135ad58e53260376cc65edff0f3480 and the balance is sufficient. What’s wrong? error info:

Starting estimateFee example Established connection with the client Building transaction Calling EstimateFee panic: Failed to estimate fee: Transaction execution error

KillerJi commented 3 months ago

the testnet eth contract address and method: someContract string = "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" //Replace it with the contract that you want to invoke contractMethod string = "transfer"