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,126 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,210 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,350 points
1,203 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,910 points
1,777 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,354 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
824 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,663 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,215 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,210 points
1,237 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,210 points
1,341 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,210 points
2,290 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