简体   繁体   English

与部署在以太坊测试网rinkeby上的智能合约进行交互

[英]Interacting with a smart contract deployed on ethereum testnet rinkeby

I have just started learning blockchain engineering and I have a few problems I have dealt with. 我刚刚开始学习区块链工程,但遇到了一些问题。

I have just deployed a simple smart contract on a rinkeby test network using remix IDE and Metamask. 我刚刚使用remix IDE和Metamask在rinkeby测试网络上部署了一个简单的智能合约。

I want to make a simple interaction with my smart contract, read a value or something similar. 我想与我的智能合约进行简单的交互,读取值或类似内容。 How should I do it? 我该怎么办? I am working on AWS server using Ubuntu OS. 我正在使用Ubuntu OS在AWS服务器上工作。 I have installed node.js, npm, web3.js and geth. 我已经安装了node.js,npm,web3.js和geth。 What my next steps should look like? 我的下一步应该是什么样? I have already set up a node on rinkeby network by typing geth --rinkeby . 我已经通过键入geth --rinkeby在rinkeby网络上设置了一个节点。 I am using VIM IDE to code, how should I deploy a web3.js library into the IDE? 我正在使用VIM IDE进行编码,如何将web3.js库部署到IDE中? Would this code deploy a web3.js library which I could use to connect to ethereum network?: const Web3 = require('web3'); const provider = new Web3.providers.HttpProvider('http://localhost:7545'); const web3 = new Web3(provider); 这段代码会部署一个可用于连接以太坊网络的web3.js库吗: const Web3 = require('web3'); const provider = new Web3.providers.HttpProvider('http://localhost:7545'); const web3 = new Web3(provider); const Web3 = require('web3'); const provider = new Web3.providers.HttpProvider('http://localhost:7545'); const web3 = new Web3(provider);

What would be the steps to interact with my ETH smart contract and read a value from it from where I am right now, using only AWS Ubuntu server? 仅使用AWS Ubuntu服务器与我的ETH智能合约进行交互并从我现在的位置读取值的步骤是什么?

Thank you for the help. 感谢您的帮助。

First, you have to write functions to read data, in your smart contract(I am assuming that you have done it). 首先,您必须在智能合约中编写函数以读取数据(我假设您已完成)。

If you just want to interact with your smart contract, then there are options for that on RUN tab of your remix IDE. 如果您只想与智能合约进行交互,则在remix IDE的“运行”选项卡上有一些选项。 Or you can try this to interact with your contract using metamask. 或者你可以尝试与使用metamask您的合同进行互动。 You can also go the way you are doing it right now, by creating your own node and interacting with it via self-made API on a server, but that is a lengthy task to do as compared to the 2 above-mentioned methods. 您还可以通过创建自己的节点并通过服务器上的自制API与之交互来按自己的方式进行操作,但是与上述两种方法相比,这是一项艰巨的任务。 But if you want to go that way, just tell me, I can provide you some info. 但是,如果您想那样做,请告诉我,我可以为您提供一些信息。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM