简体   繁体   English

建立React前端以实现以太稳固智能合约

[英]Building React front end for etherum solidity smart contract

I am new to react and solidity however I am doing one project for just learning but I am unable to understand how to create react front end of Solidity project. 我是新的反应和坚定但我正在做一个项目只是为了学习,但我无法理解如何创建Solidity项目的反应前端。

pragma solidity^0.5.0;
pragma experimental ABIEncoderV2;

contract I2Chain {

     event FileChained(string checksum, 
     address indexed user, 
     uint timestamp,
     uint fileSize, 
     uint fileTimestamp, 
     string fileType, 
     string fileName);

    event FileShared(string checksum, 
    address indexed user,  
    address indexed recipient,
    uint attributes, 
    uint tenure, 
    uint timestamp);

event FileRead(string checksum, address indexed user, uint timestamp);

event FileDeleted(string checksum, 
address indexed user,
uint timestamp);

event PubKeyUpdate(address indexed user, string pubKey);

mapping(address => string) public publicKeys;

function PublishFile(string memory _checksum,
uint _fileSize,
uint _fileTimestamp, 
string memory _fileType,
string memory _fileName) 
public {

 emit FileChained(_checksum, msg.sender, now, 
 _fileSize,_fileTimestamp, _fileType, _fileName);
}

function ShareFile(string memory _checksum, address _recipient, 
uint _attributes, 
uint _tenure) public {

emit FileShared(_checksum, msg.sender, _recipient, _attributes, 
_tenure, now);
}

function ReadFile(string memory _checksum) public {
    emit FileRead(_checksum, msg.sender, now);
}

function DeleteFile(string memory _checksum) public {
    emit FileDeleted(_checksum, msg.sender, now);
}

function setPublicKey(string memory _pubKey) public {
    publicKeys[msg.sender] = _pubKey;
    emit PubKeyUpdate(msg.sender, _pubKey);
}

function getPublicKey(address _user) 
view public returns(string memory)  {

return publicKeys[_user];
  }
}

I have deployed the contract into truffle and generate the ABI of contract, however I didn't understand how to create the front-end with this ABI. 我已经将合同部署到松露并生成合同的ABI,但我不明白如何用这个ABI创建前端。 Note:p When I deployed into remix IDE I am getting all function interface(please see the attachement enter image description here 注意:p当我部署到remix IDE中时,我获得了所有功能界面(请参阅附件, 在此处输入图像说明

Please suggest and help me how can I create UI for this contracts all function so user can intact with my smart contract and blockchain? 请建议并帮助我如何为这个合同创建所有功能的用户界面,以便用户可以完整地使用我的智能合约和区块链?

If you're new to both, i think you should follow this tutorial where they use drizzel to connect the blockchain with the frontend. 如果你是两个新手,我认为你应该按照本教程使用drizzel连接区块链和前端。

https://truffleframework.com/tutorials/getting-started-with-drizzle-and-react https://truffleframework.com/tutorials/getting-started-with-drizzle-and-react

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为Solidity项目构建React前端 - Building React front end for Solidity project 通过前端反应表单创建和部署智能合约 - Creating and deploying a smart contract through a front end react form 如何从 React 前端向智能合约发送可变数量的以太币? - How to send variable amount of ether to smart contract from React front end? 智能合约:如何在 React 中获得 Solidity function 的回报? - Smart contract: How to get return of Solidity function in React? Solidity:从我的智能合约中显示价值以做出反应的问题 - Solidity : Problem to display value from my smart contract to react 来自前端问题的智能合约交互 - Smart contract interaction from front-end issue React,Solidity,Ethereum:我无法创建可正确调用智能合约功能的React按钮 - React, Solidity, Ethereum: I can't create a React button that correctly calls a smart contract function 如何将 Solidity 智能合约与移动应用程序连接起来 - How to connect solidity smart contract with mobile app 我无法使用 react 和 web3 从我的solidity 智能合约中检索一致的信息 - I can't retrieve consistent information from my solidity smart contract using react and web3 尝试从 react js 中获取 Solidity 智能合约中的数据时返回 NULL 值 - NULL value returned when trying to fetch data from solidity smart contract from react js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM