Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link Javascript to Solidity?

Is it possible to link/connect/ send a signal from JavaScript code into Solidity/Ethereum?


1 Answers

You can use web3.

There is a different syntax for interfacing with contracts. Depending on if the contract is already deployed or you need to do that yourself.

When you have the contract instance you can then call contract methods.

const ChessGame = web3.eth.contract(abiArray);
const contractInstance = ChessGame.at(address);
contractInstance.declareWinner(winner, function (err, res) {
  // do something
});

I personally think web3 is a little cumbersome. I recommend checking out Truffle and following some of their tutorials to get up to speed.

like image 159
Dane Pilcher Avatar answered Jun 01 '26 09:06

Dane Pilcher



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!