Developers Forum for XinFin XDC Network

dendenski
dendenski

Posted on

Contract not working

Hi, I deploy a test contract here, https://apothem.blocksscan.io/address/xdc014A18E0631C8126450d8D9D9e59F4D23A424bF0#readContract

this contract is working on eth, bsc, avax, polygon and harmony chain, not sure why it is not working on xdc chain.

Discussion (13)

Collapse
gzliudan profile image
Daniel Liu • Edited on

The format of ["1000000000000000000","1000000000000000000"] should be [1000000000000000000,1000000000000000000]. Does your contract on XDC chain has enough XDC coin to pay out?

I deployed your contract to xdc2e78f2ACd8A5CA6dD5B0B8Fb502E3ea160E54C00. And I can execute function disperseXdc with parameters ["0x48800ede4Be8DabAFDCD4bdb05b099dB2b236846","0x796c0E3A2e78a699502a35a65f9734a355210036"] and [1000000000000000000,1000000000000000000] successfully. The transaction is explorer.apothem.network/tx/0x4ce6... .

Collapse
dendenski profile image
dendenski Author • Edited on

how did you make it work? I tried it on my end it still fails, I'm using remix.xinfin.network

Collapse
gzliudan profile image
Daniel Liu

I use remix deploy contract, and call function disperseXdc.

Thread Thread
dendenski profile image
dendenski Author

I'm using remix.xinfin.network or should I use remix.ethereum.org/?

Thread Thread
gzliudan profile image
Daniel Liu

I use https://remix.ethereum.org/ with RPC https://erpc.apothem.network/

Collapse
dendenski profile image
dendenski Author

it working now.. thanks!! BTW do you think is it possible to use the XDC from the contract sender instead of transferring the tokens to contract?

Collapse
gzliudan profile image
Daniel Liu

This depends your business requirements. Maybe WXDC is more convenient than XDC.

Collapse
dendenski profile image
dendenski Author

Hi have you tried sending some XDC instead of 0? still getting tmap error even after changing the format

Collapse
gzliudan profile image
Daniel Liu • Edited on

I add a function receive() external payable {} in contract HummingbotMinerPayouts. And deployed it at xdc2e78f2ACd8A5CA6dD5B0B8Fb502E3ea160E54C00. Then transfer 100 XDC to this contract. At last call function disperseXdc with parameters ["0x48800ede4Be8DabAFDCD4bdb05b099dB2b236846","0x796c0E3A2e78a699502a35a65f9734a355210036"] and [1000000000000000000,1000000000000000000] successfully. You can check balance of xdc48800ede4Be8DabAFDCD4bdb05b099dB2b236846 and xdc796c0E3A2e78a699502a35a65f9734a355210036. Please check transaction explorer.apothem.network/txs/0x4ce... also.

Thread Thread
dendenski profile image
dendenski Author

thanks will try this

Collapse
gzliudan profile image
Daniel Liu

Should add function receive() into contract, so contract can receive ethers, then contract can transfer ethers to other accounts.

Collapse
anilchinchawale profile image
AnilChinchawale

Hello,

Can you share exact error here with step to reproduce it ?

Collapse
dendenski profile image
dendenski Author • Edited on

explorer.apothem.network/address/x...

using the write Contract
DisperseXdc
inputs:
["0x48800ede4Be8DabAFDCD4bdb05b099dB2b236846","0x796c0E3A2e78a699502a35a65f9734a355210036"]

["1000000000000000000","1000000000000000000"]

TypeError: t.map is not a function
at c.formatParam (9a2ee76.js:2:904212)
at 9a2ee76.js:2:902499
at Array.map ()
at c.encodeParameters (9a2ee76.js:2:902411)
at 9a2ee76.js:2:893256
at Array.map ()
at m._encodeMethodABI (9a2ee76.js:2:893230)
at m._processExecuteArguments (9a2ee76.js:2:897736)
at m._executeMethod (9a2ee76.js:2:898168)
at 932080a.js:1:17610

getting this error on console

tried running the function on remix, it only displayed
transact to HummingbotMinerPayouts.disperseXdc pending ...

tried using yodaplus safe the transaction failed:
explorer.apothem.network/txs/0x700...