Calling function in truffle console error

0 votes

How do I correctly call a function of a contract that in the truffle console?

Using the petshop example project, I migrated the contract onto the network successfully.

In the truffle console I executed:

var ad = Adoption.deployed()

This yields the reply:

undefined

When I execute ad.adopt(23); adopt being the function name and 23 being the unit parameter; I get the exception TypeError: ad.getAdopters is not a function

How to solve this error?

Oct 10, 2018 in Blockchain by digger
• 27,620 points
223 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Inside Truffle console

ContractName.deployed().then(function(instance){app = instance})
app.adopt(23)//call method on contract class

Try this inside your app.

//from App.js
App.contracts.SmartContractName.deployed().then(function(instance){
   return instance.adopt(23)//call method on contract class
}).then(function(){

}).catch(function(err){
   console.log(err);
})
answered Oct 10, 2018 by Omkar
• 65,850 points

Related Questions In Blockchain

0 votes
1 answer

Can't call contract function in truffle console

Inspect the object adoption within the console. You will ...READ MORE

answered Sep 28, 2018 in Blockchain by slayer
• 29,040 points
352 views
+1 vote
5 answers

How to solve "truffle: command not found" error in blockchain?

First try restarting the system and then ...READ MORE

answered Jul 16, 2018 in Blockchain by slayer
• 29,040 points
490 views
0 votes
1 answer

Truffle migrate fails due to missing function, but it exists in node_modules

deployer.deploy(password1, password2, deadline, {value: 100, from: accounts[0]}); ...READ MORE

answered Oct 3, 2018 in Blockchain by digger
• 27,620 points
90 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
64 views
0 votes
1 answer

Solidity geth: Error encountered during contract execution [Bad instruction]

recipes is a dynamic storage array. You need ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 65,850 points
29 views
0 votes
2 answers
0 votes
1 answer

How can I deploy a HelloWorld contract on my testrpc network?

The problem lies in the command: truffle migrate Your truffle migrate command ...READ MORE

answered Apr 27, 2018 in Blockchain by Perry
• 16,450 points

edited Aug 10, 2018 by Omkar 353 views
0 votes
1 answer
0 votes
1 answer

Not able to migrate contract in Truffle: Error: No network specified. Cannot determine current network

Make these entries in truffle.js file: module.exports = { ...READ MORE

answered Nov 29, 2018 in Blockchain by Omkar
• 65,850 points
79 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.