Error: TypeError: Cannot read property 'toXDRObject' of undefined

94 views Asked by At

I am using stellar-sdk in nodejs to make a sell offer and it is showing the error below:

Error: TypeError: Cannot read property 'toXDRObject' of undefined

My code:

import StellarSdk from 'stellar-sdk';

const stellarServer = new StellarSdk.Server(
    'https://horizon-testnet.stellar.org'
);

const account = await stellarServer.loadAccount(testAccount.publicKey);

const fee = await stellarServer.fetchBaseFee();

const SLTIssuerId = GCKA6K5PCQ6PNF5RQBF7PQDJWRHO6UOGFMRLK3DYHDOI244V47XKQ4GP;

const XLMAsset = new StellarSdk.Asset('XLM');
const SLTAsset = new StellarSdk.Asset('SLT', SLTIssuerId);

const transaction = new StellarSdk.TransactionBuilder(account, {
    fee,
    networkPassphrase: StellarSdk.Networks.TESTNET
})
    .addOperation(
        StellarSdk.Operation.manageSellOffer({
            selling: SLTAsset,
            buy: XLMAsset,
            price: { n: numerator, d: denominator },
            amount: '2'
        })
    )
    .setTimeout(180)
    .build();

Can anyone help? I am new to blockchain.

0

There are 0 answers