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 in Blockchain by Mamta
70 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 by Omkar
• 67,380 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,050 points
36 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 93 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
65 views
0 votes
1 answer
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
138 views
0 votes
1 answer
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
• 67,380 points
76 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
• 67,380 points
24 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 in Blockchain by Omkar
• 67,380 points
140 views