Calling canister from agent-js - Invalid record - What am I missing?

I’ve created a canister to simulate the ledger for some tests. I’m trying to call the canister from agent-js.

block = await ledger.send_dfx({
        to: targetAccountID,
        fee: {
          e8s: 10000
        },
        memo: 1,
        from_subaccount: null,
        created_at_time: null,

        amount: {
          e8s: icpBalance_e8s
        }
      });

It is throwing the following error an I can’t for the life of me find where my object differes from what it expects.

Uncaught (in promise) Error: Invalid record 
{to:text; fee:record {e8s:nat64}; memo:nat64; from_subaccount:opt vec nat8; created_at_time:opt record {timestamp_nanos:nat64}; amount:record {e8s:nat64}} 
argument: {"to":"0fcd6c51fda3732d70d59408b58d976f6e09c97c73e87479dcffa32626aed53a","fee":{"e8s":10000},"memo":1,"from_subaccount":null,"created_at_time":null,"amount":{"e8s":200000000}}
    at vendor.c65646c8.js:formatted:3381
    at vendor.c65646c8.js:formatted:2513
    at Array.map (<anonymous>)
    at zipWith (vendor.c65646c8.js:formatted:2513)
    at encode$2 (vendor.c65646c8.js:formatted:3379)
    at r (vendor.c65646c8.js:formatted:8610)
    at Object.n [as send_dfx] (vendor.c65646c8.js:formatted:8626)
    at F (index.56fe35f6.js:1)

from my ledger.did.js in declarations:


'send_dfx' : IDL.Func([SendTransaction], [IDL.Nat64], [])

opt t maps to [] | [t] in JS. So { from_subaccount: [], created_at_time: [], ... }

4 Likes

Thank you! That was it.