如何使用React Web应用程序部署智能合约?
为了部署智能合约,我到目前为止使用了混音IDE。但是现在,我需要创建一个允许仅点击按钮的智能合约的网站?我可以做吗?
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface AnotherContract {
function walletOfOwner(address owner) external view returns (uint256[] memory);
}
contract Demo{
uint public similarity;
uint256 public hasRedPill;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI
) {
// some code
}
function test() public view returns(uint256 ){
AnotherContract anotherContract = AnotherContract(address(0x116486FD64Ba04F7B789278B239E2e5A1e2f7b39));
return anotherContract.walletOfOwner(msg.sender).length;
}
}
假设我想使用我的React JS Web应用程序部署此演示合同。在这里,我必须首先发送构造函数参数,然后部署合同。作为回报,我需要合同的字节代码,ABI和地址。
有什么办法吗?我有可能的感觉,因为混音IDE还提供了UI来部署合同。 我是新手。请帮忙。
To deploy a smart contract I have so far used remix ide. But now I am in a need to create a website that allows to deploy smart contract just hitting a button? Can I do that?
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface AnotherContract {
function walletOfOwner(address owner) external view returns (uint256[] memory);
}
contract Demo{
uint public similarity;
uint256 public hasRedPill;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI
) {
// some code
}
function test() public view returns(uint256 ){
AnotherContract anotherContract = AnotherContract(address(0x116486FD64Ba04F7B789278B239E2e5A1e2f7b39));
return anotherContract.walletOfOwner(msg.sender).length;
}
}
Let's say I want to deploy this demo contract using my react js web app. Here I have to first send the constructor parameters then deploy the contract. In return I need the byte code, abi and address of the contract.
Is there any way to do that? I have a sense that it is possible since remix ide also provides a ui to deploy the contract.
I am new to this. Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您问题的答案将是一个很长的问题。萨加尔的建议是一个很好的领导,尽管这里需要涵盖很多。
我建议您观看下面链接的速成课程,以使您位于位置。本课程将帮助您逐步介绍很多细节(这极大地帮助了我)。我看到您已经有了一些后端知识,因此要覆盖前端,建议您跳过第10课,其中涵盖了NextJ/React。
链接到指南:
The answer to your question is going to be a VERY long one. Sagar's suggestion is a good lead although there is a lot that needs to be covered here.
I would recommend you watch the crash course linked below to get you situated. This course will help you step by step and go into quite a bit of detail (which greatly helped me). I see you already have some backend knowledge so to cover the front end I would suggest you skip to lesson 10 where NextJS/React are covered.
Link to guide: Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript
cd
,然后truffle.config.js
中的提供商,在模块内添加以下片段。Exports:
,它应该创建
abi Array
合同地址
在.json
文件中cd
into it, thenIn
truffle.config.js
, add the following snippet inside the module.exports:That's it, it should create an
ABI array
andcontract address
in the.json
file