Moralis-JS-SDK
Moralis-JS-SDK copied to clipboard
Moralis Transfer in NodeJS SDK not mapping parameters correctly.
New Bug Report
Checklist
- [ x] I am not disclosing a vulnerability.
- [ x] I have searched through existing issues and the Moralis Forum.
- [ x] I can reproduce the issue with the latest SDK release, and my server is updated to the latest version.
Issue Description
When using the Moralis.transfer(options) command in NodeJS SDK it appears to map the option parameters incorrectly.
Steps + code to reproduce
Here is an example endpoint in the latest stable version of NodeJS and Latest version of Moralis (1.5.9)
app.post('/transfer-test', async(req, res) => {
const Moralis = require('moralis/node');
console.log(Moralis.CoreManager.get("VERSION"))
await Moralis.start({ serverUrl, appId, masterKey, moralisSecret: process.env.moralis_secret });
await Moralis.enableWeb3({privateKey: process.env.metamask_private_key});
const options = {
type: "erc1155",
receiver: "receiverWalletAddress",
contractAddress: process.env.contract_address,
tokenId: 1,
amount: 1,
};
let transaction = await Moralis.transfer(options);
console.log(transaction, 'transaction details');
const receipt = await transaction.wait();
console.log(receipt, 'transaction finished');
})
Actual Outcome
If you look at the log output for transaction and receipt you'll notice that the to field in both of them is the contractAddress instead of the receiver.
You'll also notice in the receipt log that the contractAddress comes through as null.
The transaction get's a transaction hash and appears to go through, but never actually goes through.
Expected Outcome
Expected the to field to be mapped to the reciever field and that the transaction would finish.
Environment
NodeJS 16.14.2 Moralis 1.5.9 Windows 10 Rinkeby Test Network
Server
- Moralis server version:
0.0.359
Client
- Moralis SDK version: `1.5.9
- Operating system:
Windows 10 - Browser:
Terminal CMDER
Logs
See code to reproduce above.
This appears to be happening in the browser as well.
What do you mean with The transaction get's a transaction hash and appears to go through, but never actually goes through.?
The fact that the to is the contractAddress is correct, since you are making a transaction to the token contract, to transfer a token from one address to another address. So the transaction is executed on the contractAddress.
We are going to format the response of Moralis.transfer in a nicer way in the next version of the sdk, as I can see that this can be confusing. Right now you get the "raw transaction response" back from the transaction.
If you want to verify the transaction, then you can check the logs in the result and look for the transfer events from EIP1155 (https://eips.ethereum.org/EIPS/eip-1155)