Node nem-sdk: How to get account that transferred to my account [SOLVED]

Hi Guys,

At this time i am working on application that work with NEM blockchain, at this time i need to know who transferred money to our account in my application to charge their account in my layer, i am using this code:

let nem = require("nem-sdk").default;
let endpoint = nem.model.objects.create("endpoint")(nem.model.nodes.defaultTestnet, 
nem.model.nodes.defaultPort);
nem.com.requests.account.transactions.incoming(endpoint, 
"MY PUBLIC ACCOUNT ADDRESS").then(function(res){
console.log(res.data[3]);
}, function(err){
console.log(err);
});  

but the data does not mention the account, i see it is available in my wallet. can you please let me know how i can have Public Address of person that transferred XEM to my account.

Looking forward to hearing from you.

Best Regards,
Majid A.

1 Like

Hello,
In transaction details you have signer field. This is public key of sender.
Next you can get address using /account/get/from-public-key endpoint (https://nemproject.github.io)

Not sure how wallet does it (maybe it calculates on client side without api call)

Thank you for your reply.

At this time i am using node nem-sdk and work as follow:

console.log(res.data[3].transaction.signer);
var fmt = nem.utils.format.pubToAddress(res.data[3].transaction.signer);
console.log(fmt);

but it return data that is not valid.

I want to know what is equal to /account/get/from-public-key in nem-sdk?

Hi again,

I found this code and it works perfectly.

nem.model.address.toAddress(res.data[3].transaction.signer.toString(), nem.model.network.data.testnet.id);

1 Like

Great :slight_smile: