我们可以将Solidity与NodeJS一起使用吗? [英] Can we use Solidity with NodeJS?

查看:181
本文介绍了我们可以将Solidity与NodeJS一起使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用NodeJs来开发智能合约的区块链系统,并使用Solidity来实现智能合约,我在Google上找到了它,但是我没有找到答案?

I want to develop a blockchain system with smart contract using NodeJs for blockchain and Solidity for smart contract, i Google'd this but i found no answer ?

实际上,我使用JavaScript和新语言开发了一种用于智能合约的区块链系统,但是这种语言没有包含很多指令,因此使用稳固性将非常有用,我想知道是否有可能在区块链上为用户提供稳固性由javascript开发?

actually, i developped a blockchain system using javascript and new langage for smart contract, but this langage doesn't contain a lot of instruction so using solidity will be very useful, i wonder if possible to user solidity on blockchain chains which are developped by javascript ?

如果有任何帖子,说明如何使用它.预先谢谢你.

And if there is any post contains a description of how using that. Thanks you in advance.

推荐答案

是的,可以使用 truffle 进行编译以将其压缩为JSON文件,然后将其导入到Javascript代码中并使用它.

Yes you can, you use truffle to compile to contract to JSON file and then import it to your Javascript code and use it.

https://www.trufflesuite.com/docs/truffle/getting-started/compiling-contracts

  • 首先,您松露编译以生成您的json文件
  • 将json文件导入您的代码
  • const your_contract = web3.eth.contract(contract.json.abi)
  • 常量合同= your_contract.at(<您的合同地址)
  • First, you truffle compile to generate your json file
  • Import the json file to your code
  • const your_contract = web3.eth.contract(contract.json.abi)
  • const contract = your_contract.at(<your_contract_address)

然后,您可以使用合同的方法.合同.<您的功能>

And then after that, you can use your contract's methods. contract.<your_function>

这篇关于我们可以将Solidity与NodeJS一起使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆