RootSoft / algorand-dart

Unofficial community SDK to interact with the Algorand network, for Dart & Flutter
MIT License
36 stars 16 forks source link

Unable to set a flat fee for an ABI method call when passing params #42

Open jeemoney opened 1 year ago

jeemoney commented 1 year ago

I'm having trouble setting a flat fee on an ABI method call when I use the suggested params.

I have a call txn grouped with a payment txn and those trigger an inner txn from the smart contract. I'm trying to fund all 3 txns on the method call, but when I get the suggested params and pass those to MethodCallParams(), it sets the "fee" field and throws an error if I also set the "flatFee" arg as these cannot both be set. Setting the "fee" arg doesn't help as it appears the value in the TransactionParams params arg overrides this.

This isn't a hard-blocker as there are several workarounds. Currently, I'm just explicitly setting the suggested param fields in the MethodCallParams constructor, and it works as intended.

Am I missing something with the way this is intended to be done? I'm used to always passing the suggested params when building transactions, but I wasn't able to figure out how to do that and override/set the flat fee to cover all 3 txns, and I was ending up with either insufficient fee errors when leaving it as the default or a very large fee when not setting "flatFee"

Here's the addMethodCall code. Thanks!

await atc.addMethodCall( MethodCallParams( applicationId: appID ?? 0, sender: account.address, signer: account, method: _abiContract!.methods .firstWhere((element) => element.name == "setup_contract"), methodArgs: setup_args, fee: null, flatFee: BigInt.from(3000), params: suggestedParams, ), );

RootSoft commented 1 year ago

@jeemoney Thank for the feedback. I'll try to find some time to reproduce and fix this