I created an asset (MCoin) on Stellar test-net. I made a sell-offer of 200 MCoin in exchange for XLM and then an offer of buying 200 MCoin for XLM.
But ther orders didn't match.
Here is the script I used to make an offer:
var MCoin = new StellarSdk.Asset('MCoin', 'GCKRPJXPGNHBPMRCXEX4MDH532BN5RLUJJOMVACA3CB7E2LWSTKTB5U2');
var XLM = StellarSdk.Asset.native();
server.loadAccount(distributor.publicKey)
.then(function(account){
var transaction = new StellarSdk.TransactionBuilder(account)
.addOperation(StellarSdk.Operation.manageOffer({
selling: MCoin ,
buying: XLM,
amount : '200',
price: 2,
offerId: 0,
}))
.build();
transaction.sign(distributorKeyPair);
//console.log(transaction.toEnvelope().toXDR('base64'));
server.submitTransaction(transaction)
.then(function(transactionResult){
//console.log(JSOn.stringify(transactionResult));
console.log('\n Success!')
})
.catch(function(err){
console.log('An error has occured');
console.log(err);
})
})
.catch(function(e){
console.log(e);
})
When I checked the offers from the accounts, I could see selling
and buying
was [Object]. The response when I checked for offers is:
{ records:
[ { _links: [Object],
id: 221373,
paging_token: '221373',
seller: 'GB3K552PTUQB26X4LUNGPO7FN5GZGQAO2PXMKPCJ5A45ZJISANHFOHPR',
selling: [Object],
buying: [Object],
amount: '200.0000000',
price_r: [Object],
price: '2.0000000',
self: [Function],
offer_maker: [Function] },
{ _links: [Object],
id: 221566,
paging_token: '221566',
seller: 'GB3K552PTUQB26X4LUNGPO7FN5GZGQAO2PXMKPCJ5A45ZJISANHFOHPR',
selling: [Object],
buying: [Object],
amount: '200.0000000',
price_r: [Object],
price: '2.0000000',
self: [Function],
offer_maker: [Function] } ],
next: [Function: next],
prev: [Function: prev] }
Can anyone guide on what am I missing?