dsajkdadsa14222 2018-11-18 09:55
浏览 237
已采纳

如何在PHP中添加智能合约功能? [关闭]

I'm working on project with main theme - sales. So, for front end (React) and Backend(PHP).

I had a problem understanding how to use my smart contract in the project. For deploy i use ethereum wallet 0.9.0 and test network Rinkeby. In EW he is working.

Let's pretend that I have button buy in my code, and, i have function in my contract like:

function Buy() 
    public 
    payable 
{
    require (msg.sender != seller);
    require (msg.value >= price);
    orderNum++;
    safePay +=msg.value;
}

Now, how i can use it? I heard about web3.js, but (i'm not sure) i need php requests for this.

Or, if my contract deploy in ethereum-wallet Rinkeby i can use it straight from just code and don't need deploy again.

I'm beginner in this theme and can do mistake (even in the view), but will be very glad, if someone can explain this.

Thanks.

  • 写回答

1条回答 默认 最新

  • doutun1875 2018-11-18 10:40
    关注

    AFAIK, there is no official support for PHP yet. You have 2 options here to interact with Ethereum blockchain:

    1. Use JSON RPC - using curl or any HTTP client library written in PHP, you can communicate with the Ethereum blockchain. Calling data is easy. You might face some difficulties when you want to write/edit data in Ethereum blockchain because you need to deal with transaction signing and packing the data/payload.

    2. Use Web3JS - This is much easier and you'll find many resources online. The keyword that you can use is building dapp. Truffle and this YouTube channel are two good places to learn about building dapps using Web3JS.

    If you found this answer is helpful, please accept this answer and upvote. Good luck!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改