Interacting with contract method not working
Hi,
When I try to interact with contract it does not working.
let formattedKey = PrivateKey.trimmingCharacters(in: .whitespacesAndNewlines)
let dataKey = Data.fromHex(formattedKey)!
let keystore = try! EthereumKeystoreV3(privateKey: dataKey, password: "")!
let keystoreManager = KeystoreManager([keystore])
web3.addKeystoreManager(keystoreManager)
guard let contract = web3.contract(abiString, at: EthereumAddress("0xc6E070BCb7823E483164bB41D2297DCd8b1FAb25"), abiVersion: 2) else {
return
}
print("contract methods", contract.method())
It does not comes to print the contract methods..it stops working by return.
My contract ABI: https://api-testnet.bscscan.com/api?module=contract&action=getabi&address=0xc6E070BCb7823E483164bB41D2297DCd8b1FAb25&apikey=
Please help to find the solution
Hello.
In order to make debug process easier: Please specify full code with Networks.Custom(networkID: BigUInt(networkID) initialisation.
As I can see you are interacting with the BSC chain. I didn't test it. And BSC is out of my scope of interests. So I would be happy t merge PR with this fix.
Hi @skywinder ,
RpcUrl: https://data-seed-prebsc-1-s1.binance.org:8545/
Chain ID: Networks.Custom(networkID: 0x61)
I can able to connect with BSC. I can able to send bsc and bep20 tokens.
But cant able interact with dynamic contract method.
Please support with any solution..
Thanks
Yeah Its likely chain ID. You need to set it before the tx if you are using a private chain.
transaction?.transaction.UNSAFE_setChainID(Ennvironment.ethNetworkID)
Are you still having trouble with this?
@dangell7 yes..I cant interact with BEP20 tokens.