我正在运行一个私有的以太网络。我用的是https://aws.amazon.com/blockchain/templates/
整个设置已经完成。AWS上的设置看起来很正常。现在,我正在尝试创建帐户并检索所有这些帐户。为此,我使用如下方法。
Web3Service.js
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider(process.env.NETWORK_URL));
exports.getAccounts = function () {
return w
我使用的是next.js,在服务器端,它的web3.eth.getAccounts()返回空数组,所以这里是我的to文件,一个是来自pages的index.js,另一个是web3.js,用于获取web3的实例
index.js:
import React, { Component } from "react";
import web3 from "../ethereum/web3";
import Layout from "../components/layout";
class Index extends Component {
stati
我得到了空数组后,我尝试web3.eth.getAccounts().then(console.log);,也得到了一个警告,这是./node_modules/web3-eth-accounts/src/scrypt.js Critical dependency: the request of a dependency is an expression。在这个项目中,我首先命令了create-react-app lottery_react,然后在我的lottery_react文件夹中所做的所有更改都是修改了App.js,只使用了一行web3.eth.getAccounts().then(co
有人能告诉我为什么await不在这里工作吗?
const Web3 = require('web3');
web3 = new Web3(new Web3.providers.HttpProvider("http://<ip>:8545"));
let accounts = (async () => await web3.eth.getAccounts())();
// await was not working, here I get a promise
console.log(accounts);
// if I wait with
我正在学习ethereum,我已经用geth设置了一个私有节点。并编写一个简单的客户端来创建帐户(web3 1.0 beta34)和列表。虽然创建帐户是成功的,但它没有被列出,
用于创建帐户的
代码
var web3I = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
var accountI = new Accounts(new Web3.providers.HttpProvider("http://localhost:8545"));
var cr
我有一个智能契约,当部署到localhost: 8545 (使用Ganache)时,它与我的Web3 Dapp完美地工作。但是当我把它放到Rinkeby上时,我遇到了一些问题。
契约非常简单:它所做的就是让您设置并获取值uint变量x:
pragma solidity ^0.4.16;
contract Incrementor {
uint x;
constructor() public {
// Give x in initial value of 10:
x = 10;
}
function getX()
在加纳奇有10个以太账户。我从事一项信托项目。每当我在Nodejs中运行以下代码时:
var Web3 = require('web3');
var web3 = new Web3("ws://localhost:8545");
var acc= Promise.resolve(web3.eth.getAccounts());
acc.then(function(ins){console.log(ins[0]);});
将显示第一个帐户的地址:
📷
但我想在浏览器里看到那个地址。什么是适当的代码?
在我的开发环境中,我有一个React应用程序可以连接到浏览器的Metamask,但是部署在Netlify上的版本无法连接到Metamask。我获得web3提供程序的代码是
import Web3 from "web3"; //get the browser's web 3 provider export const web3 = new Web3(window.ethereum);
这是我用来部署在本地工作的智能契约的代码:
import { web3 } from "./web3";
import { getWarranty } from ".
我正在使用web3 1.0.0-beta.37和trufflfe创建我的第一个Dapp
当使用ganache和Metamask在app.js中获取帐户时,我得到了以下错误。
Uncaught TypeError: e is not a function in the console
以下是我的App.js代码
import React, { Component } from 'react';
import './App.css';
import FormSubmitContract from './contracts/FormSubmit.json
在尝试web3.eth.getAccounts().then(console.log);之后,我得到了空数组,这真的很奇怪,而且我还收到了一个警告,即./node_modules/web3-eth-accounts/src/scrypt.js Critical dependency: the request of a dependency is an expression。在这个项目中,首先是cmd create-react-app lottery_react,然后我在lottery_react文件夹中更改的是修改App.js和创建web3.js文件。我找不到这些文件有什么问题。请帮帮我!
我
它显示了我的index.html文件中的未明的参考错误
Vote
这是我在src/js目录下的app.js文件。
import "../css/style.css"
// Import libraries we need.
import { default as Web3} from "web3"
import { default as contract } from "truffle-contract"
// get build artifacts from compiled smart contract and c
我的react应用程序中有一组函数,我想连接到web3模式。我使用Web3和web3modal连接不同的钱包。这是我的代码:
import axios from "axios";
import { useState } from "react";
import Web3 from "web3";
import Web3Modal from "web3modal";
import WalletConnectProvider from "@walletconnect/web3-provider";
c
在启动测试后,
App.web3Provider = new web3.providers.HttpProvider("http://localhost:8545");
web3 = new Web3(App.web3Provider);
它显示10个帐户,但当访问web3.eth.accounts/web3.eth.getAccounts时,它只返回第一个帐户。哪里出了问题?