I want to call a function of the contract, something like this -

module.exports.transfer = function(to,value,){ 
   return token.methods.transfer.getData(to, value);

But I am facing the error

token.methods.transfer.getData is not a function

How do i resolve it , is getData() deprecated or their is any other way to get the data of function with desired arguments ?

web3 version - 1.0 beta



For web3 1.0 beta you should use encodeABI, from the documentation:

| improve this answer | |

for web3 1.2.1(new release) you should use it like:

    contract_interfact.methods.methodName().call({from:"address"},(err,res) => {

    contract_interfact.methods.methodName(arguments).send({from:"address"},(err,res) => {
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.