How to run a Javascript in truffle console

0 votes
Ok so I have written a Javascript for my web application. And I want to run it from my smart contract. Is there a way to do it?
Jan 24, 2019 in Blockchain by Mamta
2,506 views

1 answer to this question.

0 votes

There are two ways to do this.

You can include the Javascript in the smart contract as require like this:

truffle(development)> require('./yourfile.js')

or you can use exec command of truffle to do this:

truffle(development)> exec ./yourfile.js
answered Jan 24, 2019 by Omkar
• 69,220 points

Related Questions In Blockchain

0 votes
1 answer

How to round a number down to 8 decimal places if its over 8 decimal places in Javascript

Try it in this way: function nrOfDecimals(number) { ...READ MORE

answered Sep 12, 2018 in Blockchain by slayer
• 29,370 points
1,511 views
0 votes
1 answer

How to create an instance of contract in Truffle console?

Hi, @There, I would suggest you go through ...READ MORE

answered Jun 17, 2020 in Blockchain by Gitika
• 65,770 points
2,020 views
0 votes
1 answer

How to make sure transactions take no fee in a private Ethereum blockchain?

In a private ethereum network you have ...READ MORE

answered Mar 26, 2018 in Blockchain by Christine
• 15,790 points

edited Mar 26, 2018 by Christine 1,567 views
0 votes
1 answer

In a Blockchain, how difficult is it to modify the third to last block?

Technically, it's not difficult at all, all ...READ MORE

answered Apr 20, 2018 in Blockchain by Christine
• 15,790 points
1,027 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
1,923 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 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
• 69,220 points
1,464 views
0 votes
1 answer
0 votes
1 answer

How to create a contract in truffle?

The command you are using to create ...READ MORE

answered Dec 11, 2018 in Blockchain by Omkar
• 69,220 points
1,624 views
0 votes
1 answer

How to call a payable contract function from truffle console?

You can use a contract function, on ...READ MORE

answered Jan 24, 2019 in Blockchain by Omkar
• 69,220 points
2,588 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP