Categories
Cryptocurrency Ethereum Mastering Development

Proper way to fire smart contract function passing an array with web3js

I’m using web3js version 0.20.7 The smart contract originally had a function (called whiteListAddress(address _address, bool value) ) that took an address and a boolean value, which was called like this in the js code: var getData = Coursetro.whiteListAddress.getData(whitelistaddress,1); const paymentAddress = ‘0x…’ web3.eth.sendTransaction({ to: paymentAddress, gas: 6000000, data: getData, value: web3.toWei(0, ‘ether’) }, (err, […]

Categories
Linux Mastering Development

Hi i got this error while i was running my program, i was tryingt to change the mac-address .could anyone helo me please?

import subprocess import optparse def get_arguments(): parser = optparse.OptionParser() parser.add_option(‘-i’, ‘–interface’, dest=’interface’, help=’changing new_mac add’) parser.add_option(‘-m’, ‘–mac’, dest=’new_mac’, help=’ new_mac add’) return parser.parse_args() # interface = options.interface # new_mac = options.new_mac def change_mac(interface,new_mac): subprocess.call([‘ifconfig ‘, interface, ‘down’]) subprocess.call([‘ifconfig ‘, interface, ‘hw’, ‘ether’, new_mac]) subprocess.call([‘ifconfig’, interface, ‘up’]) print(‘ + chnaging the mac add’ + ” ” […]

Categories
Cryptocurrency Ethereum Mastering Development

Web3.js error message in Chrome, “Uncaught ReferenceError, Web is not defined”

I get the following Chrome (console) error when loading a UI for my contract using Web3. Console should print the Web3.js version number. JS is pasted below. Thank you. index.html:76 Uncaught ReferenceError: Web is not defined at index.html:76 (anonymous) @ index.html:76 index.html:110 Using web3 version: 1.2.5 index.html:114 Uncaught ReferenceError: abi is not defined at index.html:114 […]

Categories
Cryptocurrency Ethereum Mastering Development

Error: “Transaction ran out of gas. Please provide more gas:

I’m facing a little issue here, that’s the mintTo function from contract for NFT. Which I require the sender to send a value with >= 0.1 Ether: /** * @dev Mints a token to an address with a tokenURI. * @param _to address of the future owner of the token */ function mintTo(address _to) public […]

Categories
Cryptocurrency Ethereum Mastering Development

How can I set my custom gas Price and gas Limit?

I want to set my custom gas and gas Price in sendTransaction method.Currently I set it but when i send the transaction gas fee is showing 0.21 ETH in metamask. How can I solve this? web3.eth.sendTransaction({ from: currentAccount, to: toAddress, value: web3.toWei(value, ‘ether’), gasPrice: web3.toWei(“0.00001” , ‘ether’), gasLimit: ‘21000’, chainId: ‘0x1’ } Above is my […]

Categories
Cryptocurrency Development Ethereum

Logic help needed, how to transfer funds to the address who placed bets on winning team?

This is a betting application and right now -> if I place bets on HOME, the amount gets stored but I want to transfer the amount only to the address who placed bets on winning team. I have developed code until getting the winner from oraclize but cant figure out how to transfer funds to […]

Categories
Cryptocurrency Development Ethereum

Cant call solidity function from app.js while sending transaction

Solidity function As i want to call function so that oraclize can send query function betOnTeam(uint team) payable public { update(); emit LogInfo(“Oraclize query was NOT sent, please add some ETH to cover for the query fee”); if(team == 1) { if(msg.value == amount) { homeBet = msg.sender; if(homeBet != 0 && awayBet != 0) […]

Categories
Cryptocurrency Development Ethereum

Unhandled Promise Rejection Warning

Why do I keep on getting this error when I try to send ether from one of my accounts to the other? Note that when I send it between other accounts the same code works, I have checked the balance and it shows that there is actually sufficient balance. So, what’s going on here? When […]

Categories
Cryptocurrency Development Ethereum

Error: Unhandled promise rejection

I keep on getting this error whenever I run my code below: var Tx = require(‘ethereumjs-tx’).Transaction var Web3 = require(‘web3’) web3 = new Web3(‘https://ropsten.infura.io/v3/9526911a3c4843388be35f52ce95de02’) const account1 = ‘0x0539B9c9C886e93778542B553C64cb5EAfB902b1’ const account2 = ‘0xca7F442c44b079dd07324C9c7eDfe348b92f46c9’ const privatekey1 = Buffer.from(‘c986afe09588ea4d871e6b8a25821bbd0804611bc1a332c18238ca1aed18981b’ , ‘hex’) const privatekey2 = Buffer.from(‘1311767cc9f7ac6e711b12dec8949057d4148ca004b97bbfee1cf7fd2411e2d8’ , ‘hex’) var transCount = web3.eth.getTransactionCount(account1) transCount.then(count => { const txObject = { […]

Categories
Cryptocurrency Development Ethereum

Transaction hash is ‘undefined’ when running web3 code from command prompt

I wrote this java script code to send test ether to my other account: var Tx = require(‘ethereumjs-tx’).Transaction var Web3 = require(‘web3’) web3 = new Web3(‘https://ropsten.infura.io/hqRzEqFKv6IsjRxfVUMH’) const account1 = ‘0x0539B9c9C886e93778542B553C64cb5EAfB902b1’ const account2 = ‘0xca7F442c44b079dd07324C9c7eDfe348b92f46c9’ const privatekey1 = Buffer.from(‘cxxxxxxxxxxxxx5xd0804xxxxxxx238ca1aed1xxx’ , ‘hex’) web3.eth.getTransactionCount(account1 , (err, transCount) => { const txObject = { nonce: web3.utils.toHex(transCount) , to: account2 […]