web3js

How to deposit ether to an account using solidity and web3?

孤人 提交于 2021-01-29 05:49:21
问题 I am building a sample smart contract . I am trying to deposit ether from 1 account to another but the issue is amount is deducted from the sender's account but not able to deposit to receiver's account. Here is my contract code : pragma solidity ^0.5.0; contract ApprovalContract{ address public sender; address public receiver; function deposit(address _receiver) external payable { require(msg.value > 0); sender = msg.sender; receiver = _receiver; address payable _rec = receiver.make_payable(

Uncaught (in promise) TypeError: Cannot read property 'pCity' of undefined

假如想象 提交于 2020-04-30 06:36:50
问题 I am getting the error TypeError: Cannot read property 'pCity' of undefined. I am injecting web3 in angular and getting this error for every Web3 function call. This is working fine outside angular. I have imported the web3.js file in angular.json like this: "styles": [ "src/styles.scss" ], "scripts": ["https://cdn.jsdelivr.net/npm/web3@1.2.6/dist/web3.min.js"] } This is being rejected here however was resolved in a simple js file called from an html file. See the rejected promise error here

Send Raw Transaction Ethereum infura nodejs npm

我的梦境 提交于 2020-01-14 10:42:49
问题 I'm currently trying to implement an ethereum Node Connection to my Typescript/ Node Project. I'm connection to the "Infura" node server where i need to sign my transaction locally. Well, anyway. I'm signing my transaction using the npm package "ethereumjs-tx" and everything looks great. When i'm using "sendRawTransaction" from web3 my response is an tx-id which means my transaction should be allready in the Blockchain. Well... it isn't My sign Transaction Function is below. private

Private Network : web3.eth.getAccounts() always send empty array

白昼怎懂夜的黑 提交于 2020-01-02 09:58:16
问题 I am running a private Ethereum network. I do use https://aws.amazon.com/blockchain/templates/ The entire setup has been done. Things look setup properly on AWS. Now, I am trying to create the account and retrieve all those accounts. For that, I am using methods as below. Web3Service.js var Web3 = require('web3'); var web3 = new Web3(new Web3.providers.HttpProvider(process.env.NETWORK_URL)); exports.getAccounts = function () { return web3.eth.getAccounts(); }; exports.createAccount = function

How to render value in promises on button click in react?

非 Y 不嫁゛ 提交于 2019-12-24 22:33:49
问题 I have two modules App.jsx import React from 'react'; import ReactDOM from 'react-dom'; import {accounts} from './contract.jsx'; class App extends React.Component{ constructor(props){ super(props); this.state={'text':'','accounts':'','clicked':false}; } componentDidMount = () => { this.setState({'accounts':accounts()}); } buttonAction = (e) => { this.setState({'clicked':true}); } render(){ return( <div align="center"> <Button name="get all Accounts" action={this.buttonAction}/> {this.state

Error: new BigNumber() not a number: [object Object]

馋奶兔 提交于 2019-12-24 21:05:59
问题 Getting BigNumber Error .. tried almost everything This is the web3js function call creditPoints: function() { var self = this; alert("Credit Coins"); this.setStatus("Initiating transaction... (please wait)"); var meta; MetaCoin.deployed().then(function(instance) { meta = instance; //alert("credit Points"); alert(account); return meta.creditCoin( account, {from: account,gas: 300000}); }).then(function() { console.log("Transaction complete"); self.setStatus("Transaction complete!"); // self

npm install web3 into Appcelerator Titanium SDK > 6.x

孤街醉人 提交于 2019-12-24 07:46:50
问题 I would like to install web3 into my mobile App project. However I am having issues with accessing it without having a buch of red screens saying I can't access these files within it. I tried to manually update the paths etc; What I've done is in my App folder: npm install web3 Then I see the node_modules folder in my App directory... however, I am not able to require the module in my index.js file with a simple: var Web3 = require('web3'); // throws error var web3 = new Web3(); function

How to get a value from a “Promise” object

二次信任 提交于 2019-12-20 03:56:21
问题 I started learning ethereum and web3js and noticed some functions on Web3js are asynchronous. What i want to achieve is get the account balance of a wallet and use the data for something else. My code below function getAccountBalance2(address){ var wei, balance //address = document.getElementById("addy").value return new Promise(function(resolve, reject){ web3.eth.getBalance(address, function(error, wei){ if(error){ console.log("Error with address"); }else{ var balance = web3.fromWei(wei,