texts:
I've just uploaded through my Swarm node a very straightforward AngularJs app (index.html, app.css, app.js and lib.js) using this command:

$ swarm --recursive --defaultpath /home/gjeanmart/workspace/app/build/index.html up /home/gjeanmart/workspace/app/build

I0131 22:57:16.586296 upload.go:195] uploading file /home/gjeanmart/workspace/app/build/index.html (747 bytes) and adding path
I0131 22:57:16.589043 upload.go:195] uploading file /home/gjeanmart/workspace/app/build/app.css (115 bytes) and adding path app.css
I0131 22:57:16.602917 upload.go:195] uploading file /home/gjeanmart/workspace/app/build/index.html (747 bytes) and adding path index.html
I0131 22:57:16.603232 upload.go:195] uploading file /home/gjeanmart/workspace/app/build/lib.css (121202 bytes) and adding path lib.css
I0131 22:57:16.604320 upload.go:195] uploading file /home/gjeanmart/workspace/app/build/lib.js (499417 bytes) and adding path lib.js
I0131 22:57:16.607676 upload.go:195] uploading file /home/gjeanmart/workspace/app/build/views/home.html (124 bytes) and adding path views/home.html
c9af459be737fa8d10aac633fbab05f045d5e20741399b6f6d9fc65bc6ab6d42

When I try to retrieve it through my local Swarm node [http://x.x.x.x:8500/bzz:/c9af459be737fa8d10aac633fbab05f045d5e20741399b6f6d9fc65bc6ab6d42], it works perfectly fine.

But through the swarm-gateway.net [http://swarm-gateways.net/bzz:/c9af459be737fa8d10aac633fbab05f045d5e20741399b6f6d9fc65bc6ab6d42/#!/home], it seems very unstable, sometime, I got an HTTP 400 Bad Request, sometime HTTP 404 Not Found or FAILED, INCOMPLETE CHUNK ENCODING.


texts: How to access the event log by knowing the contract address (golang)?

texts:
At the moment I develope dapps that use smart contract as storage for specific data. I use abigen to generate specific go binding to my contract. If someone try change state of the contract I use event for logging this action. But I am stuck, because I do not realy understand how can I view log history of specific event using go ethereum.

How can I use json rpc call of eth_getlogs method  and get all the logs that are stored in this contract address with  go ?

I will be appreciated for a snippet of code.

Thanks in advance!


texts:
i have a big problem i can't solve myself.

my parents bought eth a while ago and stored it on their (old) mac (mist wallet).

the wallet wasn't updated half a year or something. unfortunately the mac has no more storage to further update the blocks.

i tried to update the version of mist wallet with little success. i still can't send the eth. i also tried to link the wallet with meta mask. from what i know i need the private key to do so. i found three private keys, but i don't know how to open/read the data.

if i erase the (hidden) geth data, will that help my case in moving the eth?

what can i do from here? :(


texts: I'm getting "invalid opcode: opcode 0xfe not defined", when trying to estimate the gas fees

texts:
I'm trying to estimate gas fees of a contract that I'm about to execute. My code is as follows.
import Web3 from "web3";
const web3 = new Web3();

const estimateGasLimit = async (
  fromAddress: string,
  outputAddress: string,
  amount: number,
  gasPrice: number,
  gasLimit: number,
  chain = 1,
  contractAddress: string
) => {
  const contract = new web3.eth.Contract(minABI, contractAddress, {
    from: fromAddress,
  });

  return await contract.methods.transfer(outputAddress, amount).estimateGas();
};

I'm testing for USDT right now, whose contract address is '0xdac17f958d2ee523a2206206994597c13d831ec7'. It works perfectly for amount 1000000, which is 1 USDT as the decimal for USDT is 6, but fails for 10000000 that is 10 USDT. I get the following error
UnhandledPromiseRejectionWarning: Error: Returned error: invalid opcode: opcode 0xfe not defined
    at Object.ErrorResponse (/home/gaurav/Work/Revamped-Everything/wallet/node_modules/web3-core-helpers/lib/errors.js:28:19)
    at /home/gaurav/Work/Revamped-Everything/wallet/node_modules/web3-core-requestmanager/lib/index.js:288:36
    at XMLHttpRequest.request.onreadystatechange (/home/gaurav/Work/Revamped-Everything/wallet/node_modules/web3-providers-http/lib/index.js:98:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/gaurav/Work/Revamped-Everything/wallet/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/home/gaurav/Work/Revamped-Everything/wallet/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpResponseEnd (/home/gaurav/Work/Revamped-Everything/wallet/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
    at IncomingMessage.<anonymous> (/home/gaurav/Work/Revamped-Everything/wallet/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
    at IncomingMessage.emit (events.js:327:22)
    at IncomingMessage.EventEmitter.emit (domain.js:506:15)
    at endReadableNT (_stream_readable.js:1220:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

I am very new at ethereum and blockchain, so I would appreciate any help that I could get. Thank you.


texts: Can anyone please let me know why I should work in truffle framework to test the contracts when I have access to Remix Ide.


texts: How to create transaction signature for blockcypher ethereum API

texts:
The transaction signing process for the blockcypher ethereum API is explained here:
https://www.blockcypher.com/dev/ethereum/#creating-transactions

When their "addrs" endpoint is called, their API creates a new ethereum address, and a 64-character private key is provided.

When their "/txs/new" endpoint is called, their API provides a "tosign" string which must be used with the 64-character private key, to produce a signature.

I need to know how to create that signature, which can be used with their "/txs/send" endpoint.

I do not wish to use their signer tool, because it requires that the GO programming language is installed on my server. If I get a new server, I don't want to have to reinstall a bunch of additional libraries.

I looked at the Bitwasp examples, and could not find a method that simply creates a transaction signature.

Please provide specific instructions which describe the simplest method to create a transaction signature for the blockcypher ethereum API.


texts:
I thought I understood ERC-20 tokens. However, I wanted to purchase a small amount of basic attention token (like $5) to learn and experiment with. That's when I realized that I didn't understand them as well as I thought. The confusing part for me is basically in the transfer and storage. Allow me to use BAT as an example.

The Brave browser let's you add funds by sending Ether to your Brave wallet. The address of that wallet is provided in the Brave browser. Let's pretend that I didn't want to use all of the BAT immediately. So, I would want to store the BAT I didn't want to use on a hardware wallet like a Ledger. I'm trying this just to learn how it works. This is where I'm confused.

From my understanding, I don't see a way to send BAT to an address. Once it's in the Brave Wallet, it's there. Even if there was an option to "send" BAT to an address, I don't know what address on the Ledger to send it to. What denotes that a wallet address is a "BAT" wallet address? Does a single Ethereum wallet automatically recognize the token types? Or, does each token need it's own wallet? I've been told that Ledger wallets can hold BAT. Yet, the Ledger app only seems to recognize Ether.

So, does each ERC-20 token need it's own wallet? Or, do you just need one Ethereum wallet and the Ethereum platform recognizes the type of token?
While I've used BAT as an example, I'm trying to understand it in the context of other ERC-20 tokens as well.


texts: Calling a contract method on a specific block number using Go

texts:
Using the go-ethereum library, I'm able to call contract methods using the generated Go bindings:

balance, err := wallet.Balance(&bind.CallOpts{
    Pending: false,
    From:    sender,
    Context: ctx,
})

However, I'd like to make the above method call for a specific block number.

To do this I would need to do two things:

Get the latest block number.

There doesn't seem to be a function to do this dirrectly with the Ethereum client https://godoc.org/github.com/ethereum/go-ethereum/ethclient.

In web3.js there's a getBlockNumber() method, but I couldn't find the equivalent in Go.

Use the obtained block number to call the balance method on the smart contract.

The bind.CallOpts object doesn't allow you to specify the block number directly.

How would I go about achieving this using the go-ethereum library?


texts: When ETH Hardforks do the tokens as well?

texts:
If the ETH chain hard-forked into EthereumGold or something, would all of the ERC20 tokens and what not running on ETH at the time fork into the new blockchain as well?

I'm 95% sure the answer is yes but I'm confused about what the implications of that may be and wanted to check with more knowledgable people before I proceeded to explore those implications.


texts:
I am using Geth and ethminer to mine at DwarfPool. I used the command geth -rpc to run geth, then I open another cmd and run the command ethminer --opencl-device 0 -G -F https://eth-eu.dwarfpool.com:80/0x1c14b774cf7aae21eb4f06bebe98dd9b05c128ba do I need geth open? The wallet address I'm using is not from geth but from Jaxx.

These are the links where I got my stuff:

Geth: https://geth.ethereum.org/downloads/

Ethmiiner: https://github.com/ethereum-mining/ethminer/releases

When I run the command it tells me I'm mining 0.00MH/S


texts:
I wasn't able to get this working using the other "contracts from contracts" examples, so I thought I would post it here. There are two things going wrong:

The Sent Event in the first contract never emits anything.
The sendOrder method in the second contract never seems to execute.

Here is the sol file:

pragma solidity ^0.4.11;

contract TA2_Transfer {
    address public sender;
    address public receiver;
    uint public packageCount;
    mapping (address => uint) public balances;
    event Transfer(address from, address to, uint objCount);
    function sendToReceiver(address sender, address receiver, uint256 objCount) payable {
        if (balances[sender] < objCount) return;
        balances[sender] -= objCount;
        balances[receiver] += objCount;
        Transfer(sender, receiver, objCount);
    }
    function getBalance(address _sender) returns(uint) {
        return balances[_sender];
    }
}

contract ShippingOrder{
    TA2_Transfer public t;
    address public oOrigin;
    address public oShipper;
    address public oCarrier;
    address public oReceiver;
    uint public oCount;
    mapping (address => uint) public oBalances;
    event Sent(address shipper, address carrier, address receiver, uint objCount);
    function ShippingOrder() {
        oBalances[tx.origin] = 200;
    }
    function getBalance(address _sender) returns(uint) {
        return oBalances[_sender];
    }
    function sendOrder(address oOrigin, address oShipper, address oCarrier,  address oReceiver, uint256 oCount) payable{
        t.sendToReceiver(oOrigin, oShipper, oCount);
        t.sendToReceiver(oShipper, oCarrier, oCount);
        t.sendToReceiver(oCarrier, oReceiver, oCount);
    }
}

And here is the test file:

var ShippingOrder = artifacts.require("./ShippingOrder.sol");
contract('ShippingOrder', function(accounts) {
var meta;
var  xInt = 1;
var origin = accounts[0];
var shipper = accounts[1];
var carrier = accounts[2];
var receiver = accounts[3];
 it("should put 300 in the first account", function() {
    return ShippingOrder.deployed().then(function(instance) {
      return instance.getBalance.call(accounts[0]);
    }).then(function(balance) {
      assert.equal(balance.valueOf(), 200, "300 wasn't in the first account");
    });
  });
it("should transfer 1 package from Origin to Receiver", function() {
    return ShippingOrder.deployed().then(function(instance) {
      meta = instance;
      return meta.sendOrder.call(origin, shipper, carrier, receiver, xInt);
     }).then(function(balance) {
      return meta.getBalance.call(origin);
    }).then(function(balance) {
      origin_balance = balance.toNumber();
      return meta.getBalance.call(shipper);
    }).then(function(balance) {
      shipper_balance = balance.toNumber();
      return meta.getBalance.call(carrier);
    }).then(function(balance) {
      carrier_balance = balance.toNumber();
      return meta.getBalance.call(receiver);
    }).then(function(balance) {
      receiver_balance = balance.toNumber();
      assert.equal(origin_balance, 199, "Origin Balance Not 199");
      assert.equal(shipper_balance,0, "Shipper Balance Not 0");
      assert.equal(carrier_balance, 0, "Carrier Balance Not 0");
      assert.equal(receiver_balance, 1, "Receiver Balance Not 1");
    });
});
});

Any help would be greatly appreciated... it feels like I am close!!

Frank


texts: Dynamically calling a function on a contract

texts:
I'm trying to call different functions of a contract with a single function that has the function name passed to it as an argument.

var Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io'));
var myContract = new web3.eth.Contract(JSON.parse(data.abi), data.address);

var method = data.method // 'getWord'
myContract.methods.getWord().call().then(function(value) {
        console.log(value)
    }, function(error) {
        console.log(error)
    });

Above I have created a variable called method and its value has been set to getWord on the line below I am calling getWord()

What I'm trying to do is call whatever function is named in data.method like this...

    myContract.methods.[data.method].call().then(function(value) {
        console.log(value)
    }, function(error) {
        console.log(error)
    });

but of course it breaks and id prefer to not use eval() like this

    var myContract = new web3.eth.Contract(JSON.parse(data.abi), data.address);
    eval('myContract.methods.'+data.method+'().call()')
    .then(function(value) {
        console.log(value)
    }, function(error) {
        console.log(error)
    });

Is there another way?


texts: Just not able to install Web3 through powershell

texts:
After reading a lot of articles about how to install Web3j in windows.
I also tried following this article : https://kauri.io/generate-a-java-wrapper-from-your-smart-contract/84475132317d4d6a84a2c42eb9348e4b/a

I ran the following commands in Power shell npm install web3 npm install -g node-gyp

I got the following error :

I wanted to use Web3j to get the Javascript wrapper class for my smart contract which i had deployed using truffle and ganche-cli.

Could someone please assist me on how can I get the Javascript wrapper class for my smart contract, using powershell?

I really need some quick help, please help me out, i have a project submission due.

Thanks in advance!

Tried this as well:


texts: how i can connect android studio application with Ganache? i'm trying to build an application on android (that is my Front end) with a Smart contract (Back end) on my private Blockchain (Ganache). it's possible to do it? there are any other methods to do this?


texts: How to output all data from contract's mapping variable

texts:
Solidity enables the use of associative arrays with mapping:

mapping(address => uint256) balances;

Code can be written to iterate through this associative array.  But, how can all of the keys and values be outputted onto a terminal, webpage or downloadable file?


texts:
how can I make a contract send a percentage to a specific wallet (always)? Example that whenever a transaction is made from this token the 1% go to X wallet.

Thank you.

Ok felix dolderer thanks for do this for me brother a really apreciate this.

I dont know in what part of code put the code you already programed please.

look i leave my original actual contracto in this link how can i integrate your
code to this contract please, can you integrate the code you do for me in 2 examples (contract1 & contract2) ??

CODE OF MY CONTRACT https://pastebin.com/MEmaiVh1

thanks


texts: How to get return values when function with argument is called?

texts:
I am writing below a simple contract which stores all results of questionnaires for each ID.

contract answer{
  mapping(address => mapping(string => bool)) voters;

  struct qList {
    uint count; //The number of respondents
    mapping(address => mapping(uint => uint)) answer;
  }

  mapping(string => qList) questionnaires;

  function vote(string ID, uint qNum, uint ans) returns (bool) {
    if(voters[msg.sender][ID]) throw;
    voters[msg.sender][ID] = true;
    questionnaires[ID].count += 1;
    questionnaires[ID].answer[msg.sender][qNum] = ans;
    return true;
  }

  function getNumResult(string ID) constant returns (uint res) {
    return questionnaires[ID].count;
  }
}

The function vote can be called and mined successfully, however I cannot get the return value of vote.

Appreciate it if someone would advise the cause of this and solution to get the return value of function with arguments.


texts:
when Ethereum will switch to the proof of stack consensus mechanism as i know it will get rid of the POW going through a hard fork.

is it possible to have the similar scenario that happened before with ETC to end with a POW8ether or somthing like that?


texts: How do I change the owner of an ENS domain using MyEtherWallet?

texts: Does anyone know the exact procedure for doing this? It looks quite straightforward, but I'm unwilling to try it out without confirmation from someone who's done it already.


texts: Can't get the correct balance of a token after I restart geth node within docker

texts: I use docker to build a private network, and then I issue a token and I can get the balance correctly. however, after I stop it then restart the geth node, I can't get the right balance of the token I issued before. but if I build the private network without docker, it works well, Details pls look at https://github.com/ethereum/go-ethereum/issues/18383


texts: local var inside a function modifies another state variable

texts:
I have this very simple contract:

    pragma solidity ^0.4.18;
    contract C{
    uint public a = 9;
    uint[] public data;

    function f(uint _a) public{
        a = _a;
        uint[] y;
        y.push(2900);
    }
}

I understand that local variables of type array (uint[] y) references storage, but I don't understand why y.push(2900) modifies storage variable named a, and no matter what value I push to y it always increments variable a with one unit.
Thanks you


texts: I sent etherium to a one letter wrong address I typed  6 instead of a b amongst those letters from my mining account. I would like to know what can I do to recover those etheriums?


texts: How to update Geth to Homestead (1.3.4)?

texts: How can u update geth to Homestead version? Found this github link, but there is nothing specified about installation.


texts: Compiling error when using .value() for sending money between contracts using solidity and truffle framework

texts:
Dear fellow block builders! I am new to this field and I would like to implement my first project mimicking the famous DAO attack using re-entrance. I've programmed two smart contracts - the DAO and the Hacker. However, I could not get my contracts compiled due to the .value() method.

The DAO contains all users' balance, address and name

pragma solidity ^0.4.24;
contract Dao {
struct User {
    address addr;
    string name;
    uint balence;
    uint8 flag;
}
....
function addToBalence(string name) public payable{
    if(users[msg.sender].flag != 1) addUser(msg.sender,name,0,1);
    users[msg.sender].balence = users[msg.sender].balence + msg.value;
}

function showBalence() public returns (uint) {
    return users[msg.sender].balence;
}

function withdraw(uint amount) public payable{

    if(users[msg.sender].flag != 1) revert("user does not exist");
    else if (users[msg.sender].balence >= amount){
        msg.sender.call.value(amount)();
        users[msg.sender].balence -= amount;
    }
  }
}

Hacker (currently just a normal user) is suppose to deposit a small amount first and later using the re-entrance attack to withdraw money more than his deposit at DAO

contract Hacker {
Dao dao;
address userAddress; // the address of the user, so the money can be transfered
string userName;

constructor(string userName, address daoAddress) public {
    dao = Dao(daoAddress);
    userAddress = msg.sender;
    userName = userName;
}

function addToBalence(string name, uint amount) public payable {
    dao.addToBalence(userName).value(msg.value)(); // ERROR HERE!
}

function showBalence() public returns(uint){
    return dao.showBalence();
}

function payout(uint amount) public payable{
    dao.withdraw(amount);
}
}

However, I got error at addToBalence method in Hacker's contract, where the prompt says Member "value" not found or not visible after argument-dependent lookup in tuple() - did you forget the "payable" modifier?
        dao.addToBalence(userName).value(msg.value)();

I'm super confused since I already put the payable modifier at both DAO's and Hacker's contract. Does this mean my approach is way to simple and I could not attack DAO contract in my toy example? where did I do wrong?


texts: How to send signed transaction to blockchain from different account

texts: I have user's private key to sign a erc20-token transfer transaction in my DAPP. Now I want to send this transaction from different account so that 2nd account pay the gas fee. Is it possible through web3. Contract itself doesn't have any method to verify signature and call the transfer method, it has default transfer method. How can I achieve this?


texts: If we want to connect to regular node then we have to go through bootstrap node ? What in the case of private chain ?


texts: variables does not change while set before calling _addr.call(abi.encodeWithSignature(...))

texts:
I call a function of 1icnh smart contract named "getExpectedReturn" inside my contract's function. when I set a variable (named v1) before the call, the variable does not change but if I set a variable (named v2) after the call it works. I have no clue why it is so.
Below is a simple contract to reproduce the issue:
pragma solidity ^0.6.6;

contract A  {

    address internal constant ONE_INCH_ADDRESS = 0xC586BeF4a0992C495Cf22e1aeEE4E446CECDee0E;

    uint256 public v1 = 1;
    uint256 public v2 = 2;

    event Ev1( uint256  v1, uint256  v2);

    function A1 () public {

        v1 = 11;  /*this does not work*/

        ONE_INCH_ADDRESS.call(abi.encodeWithSignature(
                                "getExpectedReturn(address,address,uint256,uint256,uint256)",
                                                    0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE,
                                                    0x6B175474E89094C44Da98b954EedeAC495271d0F,
                                                    1000000000000000000, 100, 0));
        v2 = 22; /* this works*/

        emit Ev1(v1, v2); /* here v1 is 1 but should be 11 ! and v2 is 22*/

    }
}

the log of executing of function A is attached below:
[ { "from": "0x69A5e5e86c72aE3D57bBD25A38f63bc527176228", "topic": "0x9aa0a5ee181172acba4a8b7e3c24db463f4c218ff10a6ea1777f43817d257414", "event": "Ev1", "args": { "0": "1", "1": "22", "v1": "1", "v2": "22", "length": 2 } } ]

Any recommendation is welcomed.
PS1: The contract is deployed on a forked mainnet in remix. (the used addresses are on Ethereum mainnet, ETH:0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE, DAI:0x6B175474E89094C44Da98b954EedeAC495271d0F)


texts: Is there any protection in the Ethereum consensus or network protocol to avoid a block being mined with a timestamp 1000 years ahead of UTC time?

texts: Will other nodes refuse the mined block if the timestamp is too far apart from local or UTC timestamp or will they blindely accept the block if the PoW is correct?


texts: I was wondering if you could let me know if I would run into any issues buy building a small duo card mining rig with the ASUS 3060ti and a GIGABYTE RTX3070? Would anyone recommend a motherboard for such a project?


texts: Filtering logs for entries greater than a specific value

texts:
I know that you can filter logs in web3 by topic using:

web3.eth.filter({
   topics: ["0x00..."]
}).watch(console.log)

Is it possible to filter for a topic value greater than a given value?


texts: Ethereum mempool transaction of Uncle and Fork nodes

texts:
In the Bitcoin network when a fork happens, the block transactions from the shortest chain are reinserted again into the mempool.

In Ethereum instead we have Uncle blocks and Fork blocks. What happens to the Uncle block transactions, are they reinserted again into the mempool or the transactions remain confirmed and part of the blockchain?


texts: Calling function in token contract from another contract error

texts:
Able to call all other functions in my token contract but only on calling sellBack () function it fails

contract LoanTokens{
    function _transfer(address _from, address _to, uint _value);
    mapping (address => uint256) public balanceOf;
    function sellBack(uint tokensSelling);
    uint256 public tokenPrice;
}

contract LoanForCFL{
// some code
}

but when i call

function testEnd(uint amount) {
    m.sellBack(amount);
}

got no output (no specific error message in remix) .. in mist its showing that the transaction will fail.
But when i create a new contract with only the sellBack() function in it,it's working fine. so confused with this ..can anyone help me out here . my sellback function in token code is

function sellBack(uint tokensSelling) external{
    require(balanceOf[msg.sender] >= tokensSelling);
    uint totalTokensPrice = tokensSelling * tokenPrice;
    balanceOf[msg.sender] -= tokensSelling;
    balanceOf[owner] += tokensSelling;
    msg.sender.transfer(totalTokensPrice);
}


texts:
The only way I can work with ETH is through --rpc mode. Normally I would prefer to use the Python interface.

But I found myself in a situation where the RPC is very limited. For example, I can't create or unlock an account.

Are these all the available JSON-RPC methods or are they just not well documented?

Should I maybe switch to Javascript and use the JavaScript-API?


texts:
I'm using HardHat (repo) behind a firewall, requiring outbound connections to use a proxy. This is usually pretty easy, for example to configure NPM for using proxy, you can set environment variables HTTP_PROXY and HTTPS_PROXY.
In HardHat, when running commands like npx hardhat compile, HardHat reaches out to https://solc-bin.ethereum.org/windows-amd64/list.json to get the latest version list of the solidity compiler solc. The command fails because it cannot reach out to that address, making the fetch fail and subsequently the command fail. (Error message is below with Stack Trace)
Is there...
A) Configure HardHat to work with a proxy?
or
B) Manually install solc (with something like yarn add solc and update hardhat.config.js) and disable HardHat from checking for a list of compilers and installing a compiler?
Error:
HardhatError: HH502: Couldn't download compiler versions list. Please check your connection.
    at CompilerDownloader.downloadCompilersList (C:\Projects\myProject\node_modules\hardhat\src\internal\solidity\compiler\downloader.ts:185:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

    Caused by: FetchError: request to https://solc-bin.ethereum.org/windows-amd64/list.json failed, reason: read ECONNRESET
        at ClientRequest.<anonymous> (C:\Projects\myProject\node_modules\node-fetch\lib\index.js:1461:11)
        at ClientRequest.emit (events.js:315:20)
        at TLSSocket.socketErrorListener (_http_client.js:426:9)
        at TLSSocket.emit (events.js:315:20)
        at emitErrorNT (internal/streams/destroy.js:92:8)
        at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
        at processTicksAndRejections (internal/process/task_queues.js:84:21)

Edit/Update:
I found the task name subtask(TASK_COMPILE_SOLIDITY_RUN_SOLCJS)
 to compile using solcjs. Is there a way to configure solcjs as the default compiler? Possibly through an ENV variable?
Update May 2021:

Link to issue 1280


texts: How to send transaction with web3.eth.sendTransaction?

texts:
I am sending ether by using web3.eth.sendTransaction.
But when I send, there is error:

Failed to check for transaction receipt:

web3.eth.sendTransaction({
    from: base_address,
    to: withdrawer,
    gasLimit: GASLIMIT,
    gasPrice: GASPRICE,
    value: wei_val
})
.on('error', function(err){
    console.log('error', err);
    res.json({error: "Sending error"});
})
.on('transactionHash', function(transactionHash){

 })
 .on('receipt', function(receipt){
     var transactionHash = receipt.transactionHash;
     console.log('transactionHash', transactionHash);

 })
 .on('confirmation', function(confirmationNumber, receipt){

  });

I think I can see the transactionHash in console, but error is coming.
How can I do it?


texts: Create ether wallet account using node js and web3

texts:
Hello I want to create a ether wallet account using node js and web3. Can anyone please help me in this regard.
Thanks in advance!


texts: truffle-contract error: Number can only safely store up to 53 bits

texts:
I am using truffle-contract with a local quorum node and try to execute a smart contract method, but getting this error:

  Error: Number can only safely store up to 53 bits

That's the way I do it:

const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:22000'));

const ContractJSON = require('./build/contracts/MyContract.json');

//setting up for truffle-contract
var MyContract = truffleContract({
    abi: ContractJSON.abi,
    unlinked_binary: ContractJSON.bin,
    address: ContractJSON.address
});
MyContract.setProvider(web3.currentProvider);

var contract;
MyContract.deployed().then(instance => {
    contract = instance;
    contract.myContractMethod(
        web3.utils.toHex('abc123'),       //bytes32
        Number(123));                     //uint256
})
.then(result => { console.log("RESULT " + result); })
.catch(err => { console.log("ERROR! " + err); });

The contract itself works and I can also interact with it using truffle console, but truffle-contract gives me the above mentioned error. What am I doing wrong?


texts:
I am trying to "join the dots" around the networking aspect of Ethereum. From the documents, it seems, the underlying protocol is RLPx that powers the ÐΞVp2p Wire Protocol.

  Though TCP provides a connection-oriented medium, ÐΞVp2p nodes communicate in terms of packets. RLPx provides facilities to send and receive packets.

There is a tangential remark in the RLPx documents that it uses RLP.

  Packets are dynamically framed, prefixed with an RLP encoded header, encrypted, and authenticated. Multiplexing is achieved via the frame header which specifies the destination protocol of a packet.

The ÐΞVp2p Wire Protocol in turn supports sub-protocols of which Ethereum Wire Protocol is one.

From ÐΞVp2p docs:

  ÐΞVp2p is designed to support arbitrary sub-protocols (aka capabilities) over the basic wire protocol.

From Ethereum docs:

  Peer-to-peer communications between nodes running Ethereum clients run using the underlying ÐΞVp2p Wire Protocol.

Questions:

Can you please explain, where/how is the Ethereum sub-protocol plugged in ÐΞVp2p protocol?
Can APIs of an SDK (say, Javascript) be mapped to Ethereum sub-protocol message IDs?
Or, is the mapping to message IDs limited to clients such as Geth?


texts:
I am trying to estimate the complexity of the smart contracts I employ when later triggered. Assume I have 3 smart contracts:

contract con1{
}

contract con2{
}

contract main{
}

Assume that main triggers cont2, and con2 triggers con1. Also assume the complexity of con1 and con2 is O(n) and that of main is O(1).

When I test my contracts over the Ropsten network. There is no cost for running main. Shouldn't it be expensive since it calls con2 of complexity O(n) which will also call con1 of complexity O(n) as well? Am I missing something?

Is there a better way to analyze contract complexity? The problem is I do not want to think about it from gas price and gas limits because this is very dependent on the written code.


texts:
I'm working on a simple project. Part of that requires retrieving accounts from the web3 provider asynchronously (so that they can be used as variables in the code of my frontend). My initial investigation suggested this should be simple enough - web3.eth.getAccounts() returns a promise, so you should simply be able to await it, and I in fact found examples of people doing just that online. However, when I tried that, it didn't work. I initially used a simple structure:

var currentAccount = await web3.eth.getAccounts()

I then tried putting it inside an async method:

  async function getCurrentAccount(){
      currentAccount = await web3.eth.getAccounts();
      console.log("getCurrentAccount has resolved, returning a value of " + currentAccount);
       return currentAccount;
    }

But running this with currentAccount = getCurrentAccount() simply produced the following error:

inpage.js:1 Uncaught TypeError: e is not a function
at inpage.js:1
at inpage.js:1
at inpage.js:1
at inpage.js:1
at i (inpage.js:1)
at inpage.js:1
at inpage.js:1
at u (inpage.js:1)
at s (inpage.js:1)
at inpage.js:1

I'm not sure what's causing this. Anyone got any advice?

Thanks


texts:
When we create a new user in Geth, we need to enter a password. When initiating transactions in the future, you also need to use this password to unlock the account first. I want to know where the password is stored on Geth, is it possible to crack this password?
Hope you can give me a little help, thanks!


texts: CONNECTION ERROR: Couldn't connect to node when trying to connect to ropsten

texts:
I have Metamask installed on chrome and am connected to the Ropsten test network through there. However, whenever I try running my Javascript, I get the following error: CONNECTION ERROR: Couldn't connect to node. When I was running my code on testrpc, it was working fine, but it doesn't work when I try to connect to ropsten.

Javascript:

if(typeof web3 !== 'undefined'){
    console.log('metamask');
    web3 = new Web3(web3.currentProvider);

}

else{
    console.log('something else');
    web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}

web3.eth.defaultAccount = web3.eth.accounts[0];
var betContractInstance = web3.eth.contract([MY ABI]);
var betContract = betContractInstance.at('0xed5ae2f841ce23cfe6ea9e39984e66afbf445143');

testing.sol:

pragma solidity ^0.4.18;

contract Testing{
    address [] public adds;
    uint [] public amounts;

    function bet() public payable {
        adds.push(msg.sender);
        amounts.push(msg.value);
    }

    function give() public {
        adds[0].transfer(amounts[0]);
    }
}

The error arrises at web3.eth.defaultAccount = web3.eth.accounts[0];. I tried making web3 global but that didn't help either. Does anybody know how I can fix this? I've seen this question asked before but most of them use geth instead of metamask. Also, the setup of my project is based on this tutorial, so I'm not sure of there's anyother dependecies I need.

Thank you so much in advance.

EDIT: the output to the console is "something else", so I'm assuming it's not detecting the Web3 injected by metamask.


texts: How do I find the gasPrice of a confirmed transaction with ethers js?

texts: How do I find the gas price of a confirmed transaction with ethers js?


texts: Fast way of checking if my ethereum addresses can claim UNI tokens from uniswap?

texts: I have quite a number of addresses in eth and is there a way to check if my address can claim uni without having to sign in with each individual account using uniswap?


texts: Is possible to use a smart contract with custom buyTokens method in TestNet?

texts:
I'm trying to test a smartcontract in TestNet that is working in my private ethereum blockchain network. I can deploy it in Ropsten and Rinkeby, but I can not execute my buyTokens method from Remix. My buyTokens have a not standard implementation, is a custom buyTokens:
    function buyTokens(address _wallet,uint256 _amount, uint coin) public
    isOwner
    isEnableToSend(_wallet,_amount, isBuying)
    returns(uint256,uint256)
    {
        _totalSupply = _totalSupply.add(_amount);
        balances[_wallet][coin] = balances[_wallet][coin].add(_amount);
        emit BuyTokens(_wallet,_amount,coin,Time_now());
        return (_totalSupply,balances[_wallet][coin]);
    }

I have coin 0 (EUR), coin 1 (USD), coin N (***), coin  10 (CAD), each wallet have funds in each coin type, is possible that TestNet is not allow me use this type of buyTokens method?
The error in Ropsten and Rinkeby is:


texts: Unlocking the ethereum created in azure in azure shell

texts:
I have created an ethereum account using ethereum proof of authority in azure and metamask I have been trying to unlock my ethereum account to use it with my website
i entered  details like this in azure cloud shell
  Ssh -p 4000 adminuser@ethcyy5j4-dns-reg1.eastus.cloudapp.azure.com
Then its password and account like this
Then connecting to javascript console

it gives an error


texts: ERC20 is an abstract contract or an interface and cannot be deployed

texts:
i am trying to deploy a test erc20 token with truffle on ganache-cli
My migration file name 2_deploy_contracts.js here is the code for it:

var erc20 = artifacts.require('./ERC20.sol');

module.exports = function(deployer)
{
    deployer.deploy(erc20);
}

When i deploy my ERC20 contract i get this error:

2_deploys_contract.js
=====================
Error:  *** Deployment Failed ***

"ERC20" is an abstract contract or an interface and cannot be deployed.
   * Import abstractions into the '.sol' file that uses them instead of deploying them separately.
   * Contracts that inherit an abstraction must implement all its method signatures exactly.
   * A contract that only implements part of an inherited abstraction is also considered abstract.

    at Deployer._preFlightCheck (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-deployer/src/deployment.js:178:1)
    at <anonymous>
Truffle v5.0.0 (core: 5.0.0)
Node v8.11.2

Here is my ERC20.sol contract:

pragma solidity >= 0.4.0 < 0.6.0;

contract ERC20
{

    /*
    EVENT
    */
    event Transfer(address from, address to, uint256 value);
    event Approval(address tokenOwner, address spender, uint256 tokens);

    struct Allowance
    {
        uint256 amount;
        bool used;
    }
    mapping (address => uint256) balances;
    mapping (address => mapping(address => Allowance)) allowed;
    uint256 private TotalSupply;
    address internal owner;

    constructor() internal
    {
        owner == msg.sender;
        TotalSupply = 200;
        balances[owner] = TotalSupply;
        emit Transfer(address(0), owner, TotalSupply);
    }

    function totalSupply() public view returns(uint)
    {
        return TotalSupply;
    }

    function balanceOf(address tokenOwner) public view returns(uint256)
    {
        return balances[tokenOwner];
    }

    function allowance(address tokenOwner, address spender) public view returns (uint256 remaining)
    {
        return allowed[tokenOwner][spender].amount;
    }

    function approve(address spender, uint256 value) public returns(bool success)
    {
        require(balances[msg.sender] >= value, "Insufficient balance");
        require(value == 0 ||
                ( allowed[msg.sender][spender].amount == 0 &&
                !allowed[msg.sender][spender].used ), "Please set your value to 0 before you allow");
        allowed[msg.sender][spender].used = false;
        allowed[msg.sender][spender].amount = value;
        emit Approval(msg.sender, spender, value);
        return true;
    }

    function transfer(address to, uint256 value) public returns(bool success)
    {
        require(to != address(0));
        require(balances[msg.sender] >= value, "Insufficient balance");

        balances[msg.sender] -= value;
        balances[to] += value;
        emit Transfer(msg.sender, to, value);
        return true;
    }

    function tranferFrom(address from, address to, uint256 value) public returns(bool success)
    {
        require(to != address(0));
        require(value <= allowed[msg.sender][from].amount);

        allowed[from][msg.sender].amount += value;
        balances[from] -= value;
        balances[to] += value;

        if(value > 0){
            allowed[from][msg.sender].used = true;
        }

        emit Transfer(from, to, value);
        return true;
    }
}

my contract folder only have Migrations.sol for migrate and the above contract ERC20.sol
So my question is how to fix that error


texts: The code doesn't compile on remix.ethereum.org

texts:
The error is:

browser/ballot.sol:54:2: ParserError: Function, variable, struct or
modifier declaration expected.
}

The code of my token:
pragma solidity ^0.4.19;

interface Token{
   function transfer(address _receiver, uint256 _amount);
}

  contract MyFirstSafeICO{

 uint public buyPrice;

 Token public token;

 function MyFirstSafeICO(Token _token) {

    token = _token;
    buyPrice = 1000;
}

 function() payable {

     _buy( msg.sender, msg.value);
 }

 function buy() payable returns (uint ){

  uint tokens = _buy(msg.sender, msg.value);
  return tokens;
}

 function buy(address _sender, uint256 _amount) internal returns (uint){

 uint tokens = _amount/buyPrice;

  token.transfer( _sender, tokens);

  return tokens;
}


texts:
I'm trying to get the ENS for addresses, so I thought initially to use the ENS on web3

from ens import ENS
import web3 as w3
provider = w3.HTTPProvider('https://mainnet.infura.io/v3/XXXXXXXXXXXXXXXXXXXXXXX')
w3 = w3.Web3(provider)
ns = ENS.fromWeb3(w3)
kraken_address = '0x267be1C1D684F78cb4F6a176C4911b741E4Ffdc0'
print(ns.name(kraken_address))

However, even for a widely known address such as Kraken this is returning nothing.

So I went to Etherscan Name Service Lookup, still there the Kraken name is not showing when feeding the address above. Any idea, how can one programatically get these public name tags (those that are shown on etherscan) when you directly look up an address, such as the case here public_name_tag?
Is webscrapping  the only solution?


texts: Why does uint8 cost more gas than uint256?

texts:
contract A {
  uint8 a = 0;
}

costs 20150 + 2000 gas during creation.

as compared to

contract A {
  uint a = 0;   // or uint256
}

costing 5050 + 2000 gas during creation

It is odd that a variable that's taking less storage space is costing more gas. Why is that so?


texts: How can you connect a smart contract to a server

texts: I've looked into it a lot and it still makes no sense. How do you connect a smart contract to a server? I want to use web3.eth.subscribe so logs from my contract are broadcasted to the server which then manages clients accordingly. Is that possible?


texts: Mine blocks in Parity development chain?

texts:
Using the dev private development chain in Parity works well for testing out generic contract interactions, since transactions are mined instantly in a pretty slick manner. But, I'm trying to test a contract interaction that waits a number of blocks (time-locked deposits).

The only way I can see to advance blocks in the dev chain is to just send ether transactions back and forth between the testnet accounts. But that's rather tedious to try and get a bunch of blocks added to the chain.

Is there a way to add several empty blocks to the Parity dev chain all at once, or do I have to make a bunch of manual transactions to simulate the blockchain growing?


texts:
I created a Factory Contract which can create new ERC20 tokens with the parameters passed to it.
Address of the contract: (Goerli Testnet)
0x482829Ba989fBC368F9A89dFf56cdF4036F39F28

I tested the contract on remix and it works fine. But when I'm calling this function using web3js. I'm getting this error:
(node:10286) UnhandledPromiseRejectionWarning: Error: Returned error: The method eth_sendTransaction does not exist/is not available

The function definition:
function createTokens(uint _initialSupply, string calldata _name, string calldata _symbol, string calldata artistName) external{
        require(msg.sender == owner,"Unauthorized Access");
        newContract = new ERC20(_initialSupply,_name,_symbol);
        artistToERC[artistName] = address(newContract);
        emit contractCreated(artistName,artistToERC[artistName]);
    }

The function call I implemented:
    account = await web3.eth.accounts.privateKeyToAccount("3d1e49923912999811b49cde8862dc701d7493878ecd9c4e5937c5cb57444843", [ignoreLength = true]);
    var contract = new web3.eth.Contract(abi,contractAddress);
    let add = await contract.methods.owner().call();
    console.log(add);
    let peaches = await contract.methods.createTokens(2100000000,"Peaches Token","DAD","Peach Pit").send({from:account.address});
    console.log(peaches)
    let newaddress = await contract.methods.artistToERC("Peach Pit").call();
    console.log(newaddress);


texts: What happened to the official documentation of web3.js v1.0?

texts:
It should be at https://web3js.readthedocs.io/en/1.0/, but now I'm getting this:

Does anybody happen to know why this wonderful tool has been taken off line?


texts: Account Balance 0 after 1 full day of GPU mining - GTX 770 - go-ethereum and ethminer

texts:
I am a little bit new in Ethereum Mining but I took a couple of days to read, study and understand the concept. I make my system (a clean one) Linux Ubuntu 14.04 ONLY for Ethereum Mining. I installed and ran successfully go-ethereum and ethminer and followed the tutorials to ensure I am mining.

The problem is that after a full day of mining my account balance is still 0.

I am doing GPU Mining with a nVIDIA GTX 770 with 2GB RAM

I will post here a part of my go-ethereum log just to make sure I am doing everything right. But after this some information:

How I ran those application

  1 - geth account new

  2 - ethminer -G

  3 - geth --rpc --rpccorsdomain localhost 2>> geth.log &

  4 - Sometime I also do a miner.setEtherbase(eth.accounts[0]) in geth
  console just to make sure that the mining is for my my account, I am
  not sure if this works so please tell me.

geth.log

I0613 16:48:27.522828 miner/worker.go:555] commit new work on block 1698729 with 15 txs & 0 uncles. Took 24.576085ms
I0613 16:48:32.004443 core/blockchain.go:964] imported 1 block(s) (0 queued 0 ignored) including 15 txs in 13.837336ms. #1698729 [6a43bf6a / 6a43bf6a]
I0613 16:48:32.005840 miner/worker.go:555] commit new work on block 1698730 with 1 txs & 0 uncles. Took 1.249741ms
I0613 16:48:57.807846 core/blockchain.go:964] imported 1 block(s) (0 queued 0 ignored) including 1 txs in 3.698201ms. #1698730 [5e61b773 / 5e61b773]

And the ethminer shows the processing mining and stuff.

Am I doing something wrong?

Thank you.


texts: How to get BNB ERC-20 address from Binance API?

texts:
I was going trying to use the binance API for getting the token address for the BNB ERC-20 token.

But using just BNB as the asset name returns the Binance Chain address for the BNB token.

I have tried the following asset names,

BNBERC-20, BNBERC, EBNB, BNB-ERC20. You get the drift. Does anyone know what is the token/asset name so that I can retrieve the token address for BNB ERC-20 token for my account?


texts: Is any 40 character hex string a valid ethereum address?

texts: I know an ethereum address is generated by getting the last 20 bytes of the keccak-256 hash of the public key, which is 40 hex digits. I also know, an address does not need to have transactions associated to it to be valid, it just needs to have been generated by keccak-256. Does this mean any 40 character hex string is a valid address or are there some arrangements that keccak-256 will never generate?


texts:
I am sure everyone must have seen this honeypot 0xb7605ddc0327406a7ac225b9de87865e22ac5927
Where the eth is automatically send to another parent address..
How can i make the same thing? For educational purposes obviously.


texts:
Release notes of Geth 1.7 mention a new feature: local transactions journaling.

Unfortunately, I didn't find anywhere in the doc how to activate or configure this feature, and I am currently getting this warning after a node restart:

Failed to journal local transaction      err="no active journal"

Any idea of how to activate this and/or specify journaling path? Thanks.


texts: How can I talk to other contracts and store their function call returns as variables?

texts:
For example, I want to grab the current borrow rate for a token on compound.finance. In this contract InterestRateModel.sol, is there a way to call getBorrowRate from my own contract and get the return stored in a variable? I want to use that borrow rate as an input to a function. How can I do something like this?

Do I need to use an oracle or can I directly communicate with a smart contract?


texts: solidity contract invocation: raw call with string param won't be passed

texts:
I'm trying to invoke another contract in solidity using raw calls but I'm encountering some problems.

instance.call.gas(gas).value(price)(bytes4(keccak256("method(string)")), param);

this instruction is inside my second contract and while I try to get the value of the param from my first contract function its empty but instead its value is passed into msg.data.

I added an event on my first contract to see how the parameters has been sent.

function method(string param) payable external {
 Debug(param, msg.sender, msg.value, msg.data);
}

basically param is always empty while the data inside the msg are always sent and in msg.data there is my parameter value (in bytes).

I saw this discussion already and I tried to cast my string to bytes32 or passing the value without storing it into a local variable but the result is the same.

Calling a method directly with a parameter eg. instance.method2(stringParam) will work, but I can't use it in my case since I'm trying to call a payable method and I need to sent eth.


texts: How to calculate the ERC20 token price with respective to cents?

texts:
Initially, I have a ERC20 token price as 10 cents..
so,to sum it up.
1 token = 10 cents
10 tokens = 100 cents/1 dollar and so on...!
How to use cents in Wei form in solidity to calculate the token price
   function buy_token(address _to, uint256 numberOfTokens) external payable  returns(uint256) {
        require(numberOfTokens > 0);
        require(balances[owner] >= numberOfTokens);
        require(balances[_to] + numberOfTokens >= balances[_to]);

        balances[_to] = balances[_to].add(numberOfTokens);
        balances[owner] = balances[owner].sub(numberOfTokens);
        emit Transfer(owner, msg.sender, numberOfTokens);
  }

Now when someone tries to buy token, calculate the amount of tokens based on the amount input..


texts:
I want to parse the whole blockchain(I know it might sound a bit too much). I have installed both solidity and geth.
My idea was to get the current block that is being mined, essentially the current state of the blockchain, and go back to the tree until i find the genesis block.
Is that possible? It seems a bit hard because how can I get the current block? Is it possible to use another language than solidity? I tried to download the whole blockchain according to this answer, but all I got was some weird database files(I think its ms access) and I cannot read them.
Is there a better way?


texts: SenTransaction can't send Ether to a contract address

texts:
I am using openzeppelin, Ganache and truffle, here's a very simple smart contract for fundraising:

pragma solidity 0.4.24;

import 'openzeppelin-solidity/contracts/crowdsale/Crowdsale.sol';

contract PrivateSale is Crowdsale {

  constructor(address wallet,
              ERC20 token,
              uint256 rate,
              )
              public
              Crowdsale(rate, wallet, token) {
  }

}

After migrate this contract, I tried to send Ether from truffle console:

web3.eth.sendTransaction({
  from: web3.eth.accounts[2],
  value: web3.toWei(10),
  to: PrivateSale.address
})

But there's a exception here:

Error: VM Exception while processing transaction: revert
    at Eth.send [as sendTransaction] (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/method.js:145:1)
    at RequestManager.send (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:61:1)
    at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:38:1)

I also tried to transfer from account to account, it works fine, but only not work for contracts.

Here's how I deploy it:

const DemoToken = artifacts.require("DemoToken");
const PrivateSale = artifacts.require("PrivateSale");

module.exports = function(deployer) {
  const fundWallet = '0x629***'
  const rate = 1500

  deployer.deploy(PrivateSale,
                  fundWallet,
                  DemoToken.address,
                  rate);
};


texts: What's the best way to return top X values in a mapping?

texts:
Let's say I have

  mapping(address => uint) balances;

and there are over 25.000 in this.
What would be the best way to filter out top 10 values?

Example:
balances[0x0] = 100.000;
balances[0x1] = 90.000;
balances[0x2] = 85.151;
balances[0x3] = 72.444;

For me it does not matter if it's in the contract or through javascript, I just need a good way to return the top X (for example top 10) values of the array without need to go through 25k values. Is that possible?


texts:
I'm using the Ethereum Mist wallet on my desktop, but after transferring everything to a new computer I'd like to remove all traces of Ethereum from the old desktop.

What files/folders would I need to remove?

If I'm correct the wallet is not really software like all my other programs. Meaning I don't have to uninstall the program. Just deleting the shortcut and the '78.5 MBMist-win64-0-8-7.exe' file would suffice. I believe there's not a single file in the 'My programs' folder

Next to that I have to delete the 'Ethereum' and 'Ethereum wallet' folder in my 'Appdata' folder. Thereby deleting among other things the entire blockchain (which frees up a lot of hd space again) and, most importantly, the 'keystore' folder.

If I'm not mistaken that's it. Or am I forgetting something?

PS Of course I will make sure all files are properly removed and not just placed in the bin - even though they are nearly empty now.


texts: How is Ethereum integrated into real world (situations)?

texts:
For example, there exists a smart contract for marriage, known as I want half. Does the corresponding property have to exist in Ethereum too? Where will the contract gain knowledge about the IRL assets of both parties? And how can it trust the source of that knowledge?

If there is a contract about lending money with interest, what if the borrower gets "bankrupt"? How does that work?

Do all dApps have to be "open-source"? What if someone develops a similar app with the same smart contracts as competition, by cleverly imitating my code?


texts: Is switching to Proof of Stake (PoS) makes GPU mining worthless?

texts: Is switching to Proof of Stake (PoS) makes GPU mining no longer available?


texts: What does ERC20 type mean in solidity contract?

texts:
I came across Kyber Network DEX contract. On the very first line, they had declared a variable with ERC20 type as follows:

ERC20 constant internal ETH_TOKEN_ADDRESS = ERC20(0x00eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee);

And this is used throughout the contract. What does it means? As far I know, only address, uint, string, bytes, bool etc are some types.

Here's the code of smart contract: https://etherscan.io/address/0x964f35fae36d75b1e72770e244f6595b68508cf5#code


texts: What is the latest updated Tutorial I can find regarding developing dApps?

texts: I am new to Blockchain technology and Ethereum. Most of the tutorials I referred aren't applicable and I always hit bottlenecks. I need to set up a very simple application to demo a blockchains use in the supply chain using Ethereum. Can someone recommend me a good reference to refer to inorder to set up an application?


texts: Is there a way to find out how much I earned in fees from just the UniswapPair V2 contract?

texts:
Let's say I add liquidity to the ETH-USDT pool, then I remove liquidity some time later.
In between that time, trades have happened and people have added and removed liquidity too.
I only have what's inside the Pair contract, so:

reserve0
reserse1
price as a ratio reserve0/reserve1

I don't have access to:

History of swaps that have occurred
History of other people adding/removing liquidity

Is it possible to figure out how much I've earned in fees?


texts: How to optimize (lower gas) random ERC721 NFT mint?

texts:
I am creating an NFT that on-chain generates random body parts which off-chain is being combined and made into images and such. I am doing it on-chain to keep it true to the purpose of NFTs, but also because I have another function where I can combine tokens and choose which parts to keep on a new one.
Anyways, this minting of NFTs costs way too much eth atm, I am benchmarking it by minting 5 at a time, which with this current setup costs about 0.26 eth with a gas price of 150, so it uses about 1 151 894 gas. This won't really work since that almost equals the cost I've been thinking of charging for one NFT. I was wondering if anyone might have a good idea of how I could optimize my code to make it cost less, or another method to do this entirely.
These are the relevant functions:
//Generate random large number
function randomNumber() private view returns(uint) {
    return uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp, nonce)));
}

//Generate a random biased category
function generateRandomCategory() private returns(uint8) {
    nonce++;
    uint randNumber = randomNumber();

    //Each rarity has their own chance of being picked, common has 20/36, uncommon has 10/36, rare 6/36 etc
    //After choosing a rarity it will pick which category of that rarity by doing % the amount of categories
    //of that rarity + the combined amount of all previous rarities, this will give the id of that category

    uint rarityChoice = randNumber % 32;
    if(rarityChoice <= 15) { return uint8(randNumber%2);     }   //Common has 2 categories, ids start at 0
    if(rarityChoice <= 28) { return uint8(randNumber%2)+2;   }   //Uncommon has 2 categories, ids start at 2
    return uint8(randNumber%2)+4;  //Rare has 2 categories, ids start at 4
}

event NewBot(uint16 indexed _id, uint8 level, uint8 head, uint8 body, uint8 l_arm, uint8 r_arm, uint8 l_leg, uint8 r_leg);

//Mint new bot
function mintBot(uint amount) public payable {
    require(amount > 0, "You must mint atleast one bot.");
    //require((totalSupply() + amount) < maxAmount, "Not enough inventory to fulfill your request.");
    //require(msg.value == (50000000000000000 * amount), "Wrong ether amount!");
    for(uint i = 0; i < amount; i++) {
        uint8 head = generateRandomCategory();
        uint8 body = generateRandomCategory();
        uint8 l_arm = generateRandomCategory();
        uint8 r_arm = generateRandomCategory();
        uint8 l_leg = generateRandomCategory();
        uint8 r_leg = generateRandomCategory();
        uint16 _id = uint16(mint(msg.sender));
        bitsMapping[_id] = [head, body, l_arm, r_arm, l_leg, r_leg, uint8(1)];
        emit NewBot(_id, uint8(1), head, body, l_arm, r_arm, l_leg, r_leg);
    }
}

ALSO:
I did some tests to find out what was actually using up the most gas when calling the mint function (all passing the number 5 to mint 5 bots).

Current code used: 1 151 894 gas
Commenting out all the generateRandomCategory() used: 1 016 806 gas
Commenting out generateRandomCategory() AND bitsMapping[_id] used: 633 817 gas


texts: Are private variant of Ethereum or any other blockchain just a glorified distributed database?

texts:
Are private variant of Ethereum or any other private blockchain solution just a glorified distributed database?

Other than the fact that the data structure is cryptographically made immutable through SHA3 thus making it auditable, plus smart contract capability and plus the digital signatures that provide authenticity and non-repudiation, what are the distinctive differences between private blockchains and distributed database?

This is one question that I always get.


texts: Web3JS: Call Smart Contract but where is the data returned?


texts: Are these two equal: web3.eth.getCode() === type(Contract).creationCode

texts:
This question has been asked before in all sorts of convoluted ways. I am asking a very simple question and would like a very straight forward answer (if possible).
What does the result of the call to web3.eth.getCode(<contract-address>) return:

type(Contract).creationCode
type(Contract).runtimeCode

Assuming of course the contract-address is the address of Contract


texts: Total Supply manipulation after moving to a new standard with _mint function

texts:
How can I access totalSupply after refactoring to using a _mint function instead of local state?
I will need this to make transfers from the owner to another address.
Does this example show that this supply will be fixed and immutable?
What about mutability?


texts:
I am trying to run the following solidity function:

function test() payable {
msg.sender.transfer((balances[msg.sender]/1000)*this.balance);
}

Where this.balance is 0.1 Ether and balances[msg.sender] is 200, so the msg.sender should be sent 0.02 Ether. However, this never works. I have tried executing the function in the following ways (sending ether or not, it doesn't execute the transfer):

contract.test({from: web3.eth.accounts[0], gas:1000000, value: web3.toWei(0.01, "ether")})
contract.test({from: web3.eth.accounts[0], gas:1000000})

I have verified the values of balances[msg.sender] and this.balance as follows (I'm using the same msg.sender account in all cases):

function balance() constant returns (uint256) {
           return balances[msg.sender];
       }

 function contractBalance() returns (uint256) {
           return this.balance;
       }


texts:
As per the Solidity 0.4.16 documentation, contracts are similar to the concept of a Class of an object oriented language. That being said, can we create a Contract within a contract.

IF yes, then please explain with a working sample or atleast provide a classification on various kinds of nested contracts that we can create.

IF no, what is stopping us from doing i.e. practical challenges while taking this decision of not having nested contracts in solidity.

Issue raised in similar lines but NOT directly addressing this question: testrpc, contract creating contract not mined?


texts:
I have a .sol contract:

contract HelloWorld {
    string name="TEST";
    uint number;

    function HelloWorld() {

    }

    function getName() returns (string) {
        return name;
    }

    function getNumber() returns (uint) {
        return number;
    }

    function setNumber(uint _number) {
        number = _number;
    }
}

And I'm trying to write a test in javascript to call the function setNumber.
My test.js looks like this:

var HelloWorld = artifacts.require('./HelloWorld.sol');

contract("HelloWorld:getName", function(accounts) {
  it("should assert true", async function() {
    const contract = await HelloWorld.deployed();
    await contract.setNumber(54);
    await contract.getNumber();
    const result = await contract.getNumber.call();
    assert.isTrue(result === 54);

  });
});

But I am getting the following error:

Contract: HelloWorld:getName
    1) should assert true
    > No events were emitted

  0 passing (241ms)
  1 failing

  1) Contract: HelloWorld:getName should assert true:
     AssertionError: expected false to be true

Can someone help me with the syntax? Or point me in the direction for learning?

Thanks in advance..


texts: Transaction to release ETH from contract not succeeding

texts:
I pasted my contract code below and have deployed to my testrpc. The whole purpose of this contract is to lock up ETH until a specified block number. After that block number is reached, it can be released using the "release".

To test, I sent 50 ETH to it from account 0xf17f52151EbEF6C7334FAD080c5704D77216b732.

I have now exceeded the minimum block and want to call the "release" method to get my 50 ETH back into the same account. So I run this script:

HodlEthereum.deployed().then(function(contractInstance) {
  contractInstance.party({from:acct, gas:2000000}).then(function(v) {
    console.log(v)
  });
})

Unfortunately this is not working and I'm not sure why. I funded the txn with gas. The testrpc logs say "revert". Any clues?

pragma solidity ^0.4.11;

contract HodlEthereum {
    event Hodl(address indexed hodler, uint indexed amount);
    event Release(address indexed hodler, uint indexed amount);
    mapping (address => uint) public hodlers;
    uint constant targetTime = 8; // block num
    uint constant targetBlock = 8;

    function() payable {
        hodlers[msg.sender] += msg.value;
        Hodl(msg.sender, msg.value);
    }

    function release() returns (bool success){
        require (block.number >= targetBlock && hodlers[msg.sender] > 0);
        uint value = hodlers[msg.sender];
        hodlers[msg.sender] = 0;
        msg.sender.transfer(value);
        Release(msg.sender, value);
    }

    function getBalance(address hodler) returns (uint balance){
      balance = hodlers[hodler];
    }
}


texts: Doing a bulk transaction with my ERC20 token (How to do it)

texts:
I was wondering if someone has more information on how to do a bulk transaction on the Ethereum network for ERC20 tokens.

Let's say I need to send 1 ethereum to 10 users or 10 ERC20 Tokens for that matter. what would make the possibility of sending this to 10 different wallet addresses within 1 transaction?

Would love to hear from someone that has more knowledge on this.


texts: Return the struct inside array inside array

texts:
pragma solidity >= 0.4.25 < 0.6;

contract Bank {
    struct Customer {
        uint age;
    }

    Customer[][] customers;

    function foo() public {
        if (customers.length > 0) {
            Customer[] storage northBranch = customers[0];
            if (northBranch.length > 1) {
                Customer storage customer = northBranch[1];
                customer.age = 23;
            }
        } else {
            Customer memory bob;
            bob.age = 34;
            customers.length += 1;
            customers[0].push(bob);
        }
    }
}

I´m looking for examples of function that return and a array when a function is called. There are many examples but I couldent find a function that return an array with arrays inside with struct inside.

I try this but it doesnt work.

function get() external view returns (Customer[][]) {
    /*Customer[][] memory resCustomer;

    for(uint i = 0; i<customers.length;i++) {
        resCustomer[i][] = customers[i][];

    }*/

    return (customers);
}

ERROR:

  TypeError: This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.

Any idea about how can I travel across the main array to get a inside array and the struct that is inside?


texts:
I am working on a big integer library in the online compiler.
Currently having gas/computational time issues with the modulus function.

I first implemented it using repeated subtraction:

function mod2(uint8[2] x, uint8[2] m) returns(uint8[2])
{
    // Check some special cases
    if (compa(m, [0, 0]) == 0)
        throw;
    if (compa(x, [0, 0]) == 0)
        return x;
    if (compa(m, x) == 0)
        return [0, 0];
    if (compa(m, x) == 1)
        return x;

    uint8[2] memory r = x;

    // Subtract
    while (compa(r, m) != -1)
        (r,) = sub(r, m);

    return r;
}

I then tried bit-shift and subtract:

function mod(uint8[2] x, uint8[2] m) returns(uint8[2])
{
    // Check some special cases
    if (compa(m, [0, 0]) == 0)
        throw;
    if (compa(x, [0, 0]) == 0)
        return x;
    if (compa(m, x) == 0)
        return [0, 0];
    if (compa(m, x) == 1)
        return x;

    uint8[2] memory r = x;
    uint8[2] memory n = m;

    // Align most significant bit
    while (compa(x, n) == 1 && n[n.length-1] & 0x80 != 1)
        n = shift(n, 1);
    if (compa(n, x) == 1)
        n = shift(n, -1);

    // Subtract
    while (compa(r, m) != -1)
    {
        (r,) =  sub(r, n);
        n =     shift(n, -1);
    }
    return r;
}

Complete contract here. Addition and subtract is add() and sub(); shift() is bitwise-shift with positive values being right and negative values being left. Compa() is a comparison function that returns 1 if greater, 0 if equal, and -1 if less than.

The end goal is to handle 1024-bit integers as four 256-bit integers.
I am using two 8-bit integers currently as it is much easier to debug.

For both cases, with a sufficiently large difference between the input and modulo (i.e. 255 % 4), the online compiler hangs and crashes.

The second implementation scales a bit better than the first one, but it seems to have a lot of overhead.

I was wondering if this was an issue with the online complier. Or if my code is just really slow? Even if I am using naive implementations, I didn't think the code would take this long to run or crash.

Update: Optimized the bitwise-shifts, 255 % 4 no longer crashes. Still quite slow though.


texts: Events are not getting recognised TypeError: Contract.events.event is not a function

texts:
I am trying to get older state of a contract.
I have deployed contract using truffle.
my contract is

pragma solidity ^0.4.15;
contract NDA {
bytes32  party1name;
bytes32  party2name;
bytes32  pary1regaddr;

event Setparty2 (address indexed _from,bytes32 _party2name);
function NDA() {
    party1name = "Me";
}

function setparty2(bytes32 _party2name, bytes32 _pary1regaddr){
    party2name = _party2name;
    pary1regaddr = _pary1regaddr;
    Setparty2(msg.sender, _party2name);
}

function get() constant returns (bytes32, bytes32) {
    return (party1name, party2name);
}
}

When I do NDA.events
i get

truffle(development)> NDA.events
{
'0x851b88ce358750e8e352d86d0712c570afe3624e605413a620f25f7e1c012463':
{ anonymous: false,
 inputs: [ [Object], [Object] ],
 name: 'Setparty2',
 type: 'event' } }

Now I did some transactions with this contract like

NDA.at(NDA.address).setparty2("Manish", "Kumar Singh");

and then some more .

Now I want to get the previous state of contract, I am trying to use events for that but when i do

truffle(development)> NDA.events.Setparty2({fromBlock : 0 });
TypeError: NDA.events.Setparty2 is not a function

I am not able to make out how to use my events.
any help is appreciated.


texts: Wallet won't open, error loading libXtst.so.6

texts:
When I try to open the Ethereum wallet in Elementary OS (Ubuntu) I get the error

  Ethereum Wallet: error while loading shared libraries: libXtst.so.6: cannot open shared object file: No such file or directory

libxtst6 is installed, any ideas?


texts: Truffle test with non-standard deployment

texts:
I have a few contracts that I wanted to test using Mocha (that comes with Truffle). These contracts all require parameters in their constructor. I have modified the "2_deploy_contracts.js" file and it works as per requirement.

How do I code my mocha test suite so that I can invoke my customised 2_deploy_contracts.js? It seems the clean-room of Truffle test only works with simple zero-parameter constructors.


texts:
I'm new to ethereum, I followed the installation guide and chose to go with the Geth Go-implementation.

The first command i run was geth --console that downloaded all the blocks, one issue though is that it keeps doing so since blocks are mined quite often. Should I let it continue?

I'm using Ubuntu 14.4.


texts: how execute smart contract step by step?

texts:
I have a few problems understanding the step of execution of transaction in smart contract.

1-When a user send a transaction to smart contract, this smart contract is not executed immediately instead is it pooled in a transaction pool.

2- At some point of time, every EVM is chosen an transaction to execute the code in smart contract line by line.

3-If all EVMS find the same result, what happens after? Else the smart contract cancelled this transaction.

what happens after? ==> 4- the miner would collect all transactions from transaction pool,  and adds them to the newly created block and then the mining process starts between miners.( correct me if I'm wrong please in the steps)

5-finally, the blockchain is transitioned into a new state.

*How does the miner verify that these transactions are well executed by EVM?

*Does EVM play the role only in the first part of the execution of smart contract?

*Who will change state when the contract is executed? ( transaction ?)


texts: I own Ether, should I also own Ether Classic (are they one in the same)?  If I own 100 Ether and believe in the technology behind it, and have owned them for 6 months or so, do I need to purchase Ether Classic as well to stand a chance to make some money down the road.  Will Ether go away if Ether Classic succeeds, or are they one in the same?


texts: How does Casper record votes efficiently?

texts:
I keep reading about Casper doling out rewards and punishments for voters based on how they're voting. If I am understanding this correctly, it seems that Casper punishes nodes that submit votes to forks of the same height (How does Casper solve the "Nothing at Stake" issue?).

Regardless of the punishment measure, I'm interested in how the punishment is validated, as in how does Casper intend to store and communicate votes efficiently.

The simplest way is to just store all votes, which is what a lot of articles imply. This seems very inefficient both in terms of storage and network traffic and if it involves smart contracts, network processing power as well.

My question is: how does Casper store and communicate votes to enable punishment? Is it much more clever & efficient than just "recording all votes"? Thanks!


texts: Ethereum balance is not showing in my Ethereum node

texts:
I have set my ethereum node in Amazon Ec2.
I start syncing through this command
sudo geth --datadir /home/ubuntu/data/ --cache=512 --allow-insecure-unlock --rpcapi "web3,eth,personal"  --rpc --rpcaddr "0.0.0.0" --rpccorsdomain "*"  --mainnet
After a couple of days got all the latest blocks downloaded.
Now I created an account using the below command
sudo geth --datadir /home/ubuntu/data/ account new
Got this public address
Public address of the key:   0x18bfeAc7ceAa60B53647dd2c0F73fcF74c1eB3A4
To know balance I ran this below command it showed 0
sudo geth --datadir /home/ubuntu/data/ --exec 'web3.fromWei(eth.getBalance("0x18bfeac7ceaa60b53647dd2c0f73fcf74c1eb3a4"), "ether")' attach
0
yes, this is correct. Now I asked my friend to transfer a small amount to check the balance.
He transferred an amount and the transaction was successful in etherscan.
Now when I ran this command again
sudo geth --datadir /home/ubuntu/data/ --exec 'web3.fromWei(eth.getBalance("0x18bfeac7ceaa60b53647dd2c0f73fcf74c1eb3a4"), "ether")' attach
It is still showing zero.
In etherscan https://etherscan.io/address/0x18bfeac7ceaa60b53647dd2c0f73fcf74c1eb3a4 balance is showing correctly.
Any idea what I am missing. Your help will be greatly appreciated. Thanks


texts: Group sorting algorithm using max hash and quantity of accounts

texts:
Would it be possible to design an algorithm for pseudo-randomly sorting accounts into groups, by using the maximum number of accounts on Ethereum, the max value of a 256-bit number, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF,
then treat the hash of an account as a large random number.

Something similar to the algorithm

userGroup[msg.sender] = uint(userHash[msg.sender]) / (uint(maxHash) / numGroups()) + 1;

g is group index, n is account hash, k is 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, p is number of groups.

g = n / (k / p) + 1

How large does the quantity of n have to be for a similar algorithm to work ? What is the lower-bound for quantity of n when it becomes unusable ?

What would be an example of a similar algorithm ?


texts: Truffle + Infura on Mainnet: Nonce too low error

texts:
I have the following code:

const Contract = artifacts.require('./Market.sol');

module.exports = async function(callback) {
  let instance = await Contract.deployed();

  for(var i = 0; i <=200; i++){
     await instance.createListing(i, 4, {from: address, gas: 5000000, gasPrice: 2000000000})}

}

This works on Truffle and Ganache, works on Ropsten via Infura (executed via truffle exec script.js --network ropsten).

However, when I'm deploying the contract on mainnet and running truffle exec script.js --network live, it works for the first 2-3 iterations, and then I'm getting:

UnhandledPromiseRejectionWarning: Error: nonce too low

I tried reinstalling MetaMask, but the issue is still there. What could be the reason of this, and is there a way to add a chunk of code in the script or truffle.js that could help to deal with it?


texts: How to make an upgrade, e.g. Metropolis, Casper etc, at Ethereum? I mean, if someone proposes an upgrade to Ethereum network, how can it be made concrete?


texts: Can I get price feed information directly from ChainLink oracles rather than from the aggregated contract?

texts:
I've been experimenting with ChainLink recently and am fascinated of what it can do. I already used the code provided here ChainLink Docs in Python and got it to work. However, I've been searching all day to find a way to access the individual oracle prices rather than the aggregated one. I know i.e. that for BNB / USD there are 9 nodes which i found out here: ChainLink Market
I tried the API calls for the oracle contracts, result: empty responses.
Also, I've found a lot of documentation on how to do it out of a smart contract, but i have almost zero experience with solidity / smart contracts.
So: Is there a way to call the price feeds from individual oracles without using smart contracts?


texts: How to search for a dapp based on its address?

texts:
There are many websites that track dapps like http://dappradar.com or https://www.dapp.com. Unlike Etherscan one particular dapp doesn’t have to be registered on such specific website in order to be listed.
As a result, many dapps whose source code and/or tag is unknown to Etherscan can be found on such websites. Thus if you have the name of Dapp you can find its contract address

However, there are many times, where I find the address first, but not the website nor the name.
So how to search dapps by addresses instead of by name in order to find how to gamble on that game for example ?


texts: How to make a dapp compatible with browsers like Cipher and Toshi

texts: I wish to know how can we make a simple web based dapp compatible to run on browsers like Cipher and Toshi ? Is there any development or testing suite for these browsers that works in Rinkeby Network. I have installed these browsers on my android phone but could not find any options there.


texts: can't connect to web3 socket in mist console

texts:
I want to connect to my local testnet with web3. The following code works when executed in Mist:

var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
console.log("Connected to Web3 Status: " + web3.isConnected());

The output of this code is:

  Connected to Web3 Status: true

However, when debugging in my Mist console with a break point after connecting to the Web3 socket, and when I input

web3.isConnected()

I am getting 'false', even though when continuing the code from Mist, it prints

  'Connected to Web3 Status: true'

again.

How can I use the web3 socket from the mist browser console correctly?


texts: Filtering blocks on basis of transaction logs in web3j

texts:
I want to filter blocks on the basis of a log present inside transactions. How can I do that?
I don't have any contract address and want to filter all the blocks generated by all the contracts.

        EthFilter filter = new EthFilter(DefaultBlockParameterName.EARLIEST,
            DefaultBlockParameterName.LATEST,contractAddress);

I want to remove contractAddress from this filter.


texts:
Hey guys I'm a bit new to solidity,
In the offical example of ethereum they handle the relations with a map :
Pizza[] public pizzas;

// Mapping from owner to id of Pizza
mapping(uint256 => address) public pizzaToOwner;

So if you want to know the Pizzas of an user you have to iterate over the whole list
function getPizzasByOwner(address _owner)
    public
    view
    returns (uint256[] memory)
{
    uint256[] memory result = new uint256[](ownerPizzaCount[_owner]);
    uint256 counter = 0;
    for (uint256 i = 0; i < pizzas.length; i++) {
        if (pizzaToOwner[i] == _owner) {
            result[counter] = i;
            counter++;
        }
    }
    return result;
}

as far I understand : iterating over maps/arrays is all about gas, so this approac would be to thick? .
I created a similar case with a struct ( on example with colors ) that handles the relations like that
struct Holder
{
    address id;
    string name;
    Color[] colors; // tryed out without and relation map
}

mapping(address => Holder) public holders;

so getting all colors looks like this
function getColorsByAddress(address _address) public view
returns (uint256[] memory)
{
    uint256[] memory result = new uint256[](holders[_address].colors.length);

    for (uint256 i = 0; i < holders[_address].colors.length; i++) {

            result[i] = holders[_address].colors[i].id;
    }

    return result;
}

the full code example would be here
https://gist.github.com/DomEscobar/d35bbc65d8c8cdebf5cdaa1dd338161c
The question now :
What is the best practise to handle relations is there a better way?


texts: Private keys of Ethereum accounts are usually represented as 64-character hex strings. Will any such string work as a private key? Are there limitations on what the key could be? If not, I can just make a random string and use a privateKey -> address function and I have generated an account, as secure as any wallet generation library. Is this correct?


texts: How to call function via interface from another contract when calldata type is used

texts:
I have declared the following interface:

interface Test {
    function airDropMultiple(
        address[] calldata recipients,
        uint[] calldata tokenAmount
    )
        external
        returns (bool);
}

I am attempting to call it like this:

Test(ContractAddress).airDropMultiple(
    [testWalletAddress[4], testWalletAddress[3]],
    [10**18, 10**19]
);

I am receiving the following compiler error:

Invalid implicit conversion from address[2] memory to address[] memory requested.

How I can call this interface from this contract to target contract?


texts: Ethernum balance wei to ether from JSON-RPC

texts: Is there any way to get ethereum balance in "ether" rather than wei from JSON-RPC?


texts: DAO withdrawal contract - executed but no ethers

texts:
Yesterday I executed the DAO Withdrawal Contract. Everything seemed to work, all the transactions were confirmed. However, the ether did not return to my ether wallet. Apparently the transaction was listed as an "internal transaction" and I am not sure where my ethers are now. Hopefully somebody knows what went wrong and how I can fix it?

This is the TXhash: 0x073d5f9576d5971fd544e401f47c23bba47178890c1449887aa325ac88fff4e2
https://etherscan.io/tx/0x073d5f9576d5971fd544e401f47c23bba47178890c1449887aa325ac88fff4e2


texts:
I noticed that address's offer two member functions that perform the transfer of ether to the specified address. send returns false upon failure and transfer raises an exception. In the Solidity documentation they offer an example that utilizes both calls Simple Open Auction.

When should I use send and when should I use transfer?


texts: What does it mean to flush to an ethereum address

texts: If ether is sent to a contract then flushed to an address what does this mean? Does it mean the contract sends the money to a recipient?


texts: How can I sign raw transaction generated by truffle?

texts:
I can create tokens by the following way. However, I want to sign raw transaction generated by truffle so that I don't need to store my private key online. How can I get raw unsigned transaction?

$ mkdir /tmp/zonotoken-infra
$ cd /tmp/zonotoken-infra
$ truffle unbox tutorialtoken
$ npm install ethereumjs-wallet bip39 web3-provider-engine@8.6.1 web3@0.18.4 zeppelin-solidity --save
$ vi ./truffle.js
$ vi ./contracts/ZonoToken.sol
$ vi ./migrations/2_deploy_contracts.js
$ truffle compile
$ truffle deploy --network ropsten

./truffle.js

var bip39 = require("bip39");
var hdkey = require('ethereumjs-wallet/hdkey');
var ProviderEngine = require("web3-provider-engine");
var WalletSubprovider = require('web3-provider-engine/subproviders/wallet.js');
var Web3Subprovider = require("web3-provider-engine/subproviders/web3.js");
var Web3 = require("web3");
var FilterSubprovider = require('web3-provider-engine/subproviders/filters.js');

// Get our mnemonic and create an hdwallet
var mnemonic = "xxxxxxxxxxxxxxxxxxxxxxx";
var hdwallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonic));

// Get the first account using the standard hd path.
var wallet_hdpath = "m/44'/60'/0'/0/";
var wallet = hdwallet.derivePath(wallet_hdpath + "0").getWallet();
var address = "0x" + wallet.getAddress().toString("hex");

var providerUrl = "https://testnet.infura.io";
var engine = new ProviderEngine();
engine.addProvider(new FilterSubprovider());
engine.addProvider(new WalletSubprovider(wallet, {}));
engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider(providerUrl)));
engine.start(); // Required by the provider engine.

module.exports = {
  networks: {
    "ropsten": {
      network_id: 3,    // Official ropsten network id
      provider: engine, // Use our custom provider
      from: address,    // Use the address we derived
      gas: 4600000
    }
  },
  rpc: {
    // Use the default host and port when not using ropsten
    host: "localhost",
    port: 8545
  }
};

./contracts/ZonoToken.sol

pragma solidity ^0.4.4;
import 'zeppelin-solidity/contracts/token/StandardToken.sol';

contract ZonoToken is StandardToken {
  string public name = 'ZONO';
  string public symbol = 'ZONO';
  uint public decimals = 0;
  uint public INITIAL_SUPPLY = 100;

  function ZonoToken() {
    totalSupply = INITIAL_SUPPLY;
    balances[msg.sender] = INITIAL_SUPPLY;
  }
}

./migrations/2_deploy_contracts.js

var ZonoToken = artifacts.require("./ZonoToken.sol");

module.exports = function(deployer) {
  deployer.deploy(ZonoToken);
};


texts: truffle command line version older than it is in package.json

texts:
After installing Truffle with yarn add truffle, the following line shows up in package.json:
  "truffle": "^5.1.52"

In the root directory of the project, the truffle version prints out the following:
$truffle version
Truffle v4.1.12 (core: 4.1.12)
Solidity v0.4.24 (solc-js)

Why is the Truffle version from command line is one version older than it is in the package.json?


texts: Simple contract on private network is never mined

texts:
I'm trying to run the crowdsale example from the Frontier docs on a private network and local blockchain.  I can create the contract, but do not seem to be able to mine it.

You can see a gist of the code I'm running in the geth console here.

In particular, the crowdsale example involves two contracts: one called token and one called Crowdsale.  I can compile these fine with solc; given the contracts' source in crowdSrc and an unlocked account named 'foo', the following code creates the token contract as expected:

var crowdCompiled = eth.compile.solidity(crowdSrc);

var tokenContract = eth.contract(crowdCompiled.token.info.abiDefinition);

var token = tokenContract.new(
    10000
  , { from: foo
    , data: crowdCompiled.token.code
    , gas:  300000
    }
  , function(e, contract) {
      if(!e) {
        if(!contract.address) {
        console.log(
          "Contract transaction send: TransactionHash: " +
          contract.transactionHash + " waiting to be mined...");
      } else {
        console.log("Contract mined! Address: " + contract.address);
      }
    }
  })

This is mined almost instantaneously when I start mining with a couple of threads via miner.start(2):

Contract mined! Address: 0xaacc2f82f12a54172a0eb6b499a91578a5b7e0b5

and I can check its address:

> token.address
"0xaacc2f82f12a54172a0eb6b499a91578a5b7e0b5"

Now.  crowdCompiled also contains the compiled code for the Crowdsale contract, so I can create it from the unlocked account 'foo' like so:

var crowdContract = eth.contract(crowdCompiled.Crowdsale.info.abiDefinition);

var _beneficiary = foo;
var _fundingGoal = parseInt(web3.toWei(100, 'ether'));
var _duration    = 5;
var _price       = parseInt(web3.toWei(0.02, 'ether'));
var _reward      = token.address;

var crowdsale = crowdContract.new(
    _beneficiary
  , _fundingGoal
  , _duration
  , _price
  , _reward
  , { from: foo
    , data: crowdCompiled.Crowdsale.code
    , gas:  300000
    }
  , function(e, contract) {
      if (!e) {
        if (!contract.address) {
          console.log(
            "contract transaction send: hash " + contract.transactionHash +
            " waiting to be mined.");
          } else {
            console.log("contract mined, address " + contract.address);
            }
        }});

Again it is created fine:

contract transaction send: hash 0xc813953780a364f91f339a711a301188f9c546a29915ae19fd1722e335076ad8 waiting to be mined.

But it seemingly takes far longer than expected to finish mining this contract, if it indeed finishes at all.  I've kicked off miner.start(2) and waited for over fifty blocks to go through numerous times, but I've never actually managed to mine the contract.

When the miner is active I can confirm that crowdsale._eth.hashrate is a valid number (e.g. 139791, 206544, etc.).  Checking crowdsale.address yields undefined.

Why is this simple contract taking so long to mine?  Have I missed something, or is this behaviour possibly due to a bug?  Are there any useful web3 methods or other tips I'm missing to help diagnose the problem?


texts: Is it possible that an Ethereum Address starts with 0x0

texts:
Is it possible that an Ethereum Address starts with a 0 on the first place after the hex prefix?

For example:
0x0c01a1da70b4109be8789af5fd678183145dbe55


texts:
Having issues verifying my token contract on etherscan.io.

Receiving the following errors:
Note: Contract was created during Txn#
Result: Does not match the input creation bytecode found at this address

Error! Unable to generate Contract ByteCode and ABI

For some reason, the end of my Input Data does not give me a working Bytecode to use where others do.
Here's the transaction which made the contract:
0x776159bbc0f6e624e92a812ee98c1674e67a2ea3

Compiler Warning(s):

myc:1:1: ParserError: Expected pragma, import directive or contract/interface/library definition.
[
^
Any help is appreciated, I've been stuck at this point for some days, and completely clueless.

Cheers!

pragma solidity ^0.4.0;
contract Ballot {

    struct Voter {
        uint weight;
        bool voted;
        uint8 vote;
        address delegate;
    }
    struct Proposal {
        uint voteCount;
    }

    address chairperson;
    mapping(address => Voter) voters;
    Proposal[] proposals;

    /// Create a new ballot with $(_numProposals) different proposals.
    function Ballot(uint8 _numProposals) public {
        chairperson = msg.sender;
        voters[chairperson].weight = 1;
        proposals.length = _numProposals;
    }

    /// Give $(toVoter) the right to vote on this ballot.
    /// May only be called by $(chairperson).
    function giveRightToVote(address toVoter) public {
        if (msg.sender != chairperson || voters[toVoter].voted) return;
        voters[toVoter].weight = 1;
    }

    /// Delegate your vote to the voter $(to).
    function delegate(address to) public {
        Voter storage sender = voters[msg.sender]; // assigns reference
        if (sender.voted) return;
        while (voters[to].delegate != address(0) && voters[to].delegate != msg.sender)
            to = voters[to].delegate;
        if (to == msg.sender) return;
        sender.voted = true;
        sender.delegate = to;
        Voter storage delegateTo = voters[to];
        if (delegateTo.voted)
            proposals[delegateTo.vote].voteCount += sender.weight;
        else
            delegateTo.weight += sender.weight;
    }

    /// Give a single vote to proposal $(toProposal).
    function vote(uint8 toProposal) public {
        Voter storage sender = voters[msg.sender];
        if (sender.voted || toProposal >= proposals.length) return;
        sender.voted = true;
        sender.vote = toProposal;
        proposals[toProposal].voteCount += sender.weight;
    }

    function winningProposal() public constant returns (uint8 _winningProposal) {
        uint256 winningVoteCount = 0;
        for (uint8 prop = 0; prop < proposals.length; prop++)
            if (proposals[prop].voteCount > winningVoteCount) {
                winningVoteCount = proposals[prop].voteCount;
                _winningProposal = prop;
            }
    }
}


texts: web3js returns non-checksumed addresses!

texts:
Why does web3js 0.20.6 returns all-lowercase addresses on contract creation not a checksumed address?!

How to deal with this trouble?


texts: Balance returning zero after sending KETH to it

texts:
I have sent the following transactions to the account 0x2D76d8729F9Cfa5bC3CEba8a504400FE30bb53D2:

0x8667bd1859a5ccc99bcc77b38c5453195bf32b308b4038ae409b47b002546344
0x048be71bb286c0cd4546f882874e8c7d52a46ad6bb23132a2753807b67d7680b

However, when I try to query the balance using the code below, I get a balance of 0

package main

import (
    "context"
    "fmt"
    "log"
    "github.com/joho/godotenv"
    "github.com/ethereum/go-ethereum/common"
    "github.com/ethereum/go-ethereum/ethclient"
)

var myenv map[string]string

const envLoc = ".env"

func loadEnv() {
    var err error
    if myenv, err = godotenv.Read(envLoc); err != nil {
        log.Printf("could not load env from %s: %v", envLoc, err)
    }
}

func main() {
    loadEnv()

    ctx := context.Background()

    client, err := ethclient.Dial("http://kovan.infura.io/v3/<!REDACTED>)
    if err != nil {
        log.Fatalf("could not connect to Ethereum gateway: %v\n", err)
    }
    defer client.Close()

    accountAddress := common.HexToAddress("0x2D76d8729F9Cfa5bC3CEba8a504400FE30bb53D2")
    balance, _ := client.BalanceAt(ctx, accountAddress, nil)
    fmt.Printf("Balance: %d\n", balance)
}

I would appreciate pointers as to what I am doing wrong


texts: Where is the data of a transaction saved?

texts:
To introduce my question I would like to give an example.
Suppose a customer wants to join a gym. A transaction is sent and contains:

customer id
name and surname
start date
end date

The smart contract receives the transaction and creates a membership at the gym. Where is this data saved?
After some time I want to verify that the subscription has not expired and I send a checkRequest. Can I specify only the id and then the smart contract through the id search for the subscription? I mean, can the smart contract access the subscription knowing the id? Can the smart contract take the subscription that matches the sent id and do the check?
I cannot understand the difference between data saved on the blockchain permanently (when is this data saved?) and data that is saved in the smart contract (does the smart contract have storage?) Is there a difference? I know the question is trivial but I can't understand.


texts: Receiving error while getting state variable value after using selfdestruct method "Error: Returned values aren't valid, did it run Out of Gas?"

texts:
I am using selfdestruct method and passing the payable address to it but receiving the following error when trying to get the value of a state variable :
"Error: Returned values aren't valid, did it run Out of Gas?"

Do the value of state variables will get cleared on using self destruct or we can not access the variable after using selfdestruct method.

solidity version: v0.5.8

Tutorial followed: "Code your own crypto currency on Ethereum" by Gregory(lecture 10) on udemy


texts:
I have the following code snippet inside my contract:
plans[1100] = Plan(7, 3);
plans[1101] = Plan(7, 2.5);
plans[1102] = Plan(15, 4);
plans[1103] = Plan(30, 6);
plans[1104] = Plan(30, 5);

When I try to compile my contract, I encounter the following error:

CompileError: /home/nimashiri/react-dapp/contracts/TrustTrade.sol:172:31: TypeError: Invalid type for argument in function call. Invalid implicit conversion from rational_const 5 / 2 to uint256 requested.
plans[1101] = Plan(7, 2.5);

I was wondering if you help me with this case.
Thanks,
Nima.


texts: Any who has done any smart contract analysis?

texts: I want to analyze smart contract application and I wanted to know if there is a crawler for it and after the contracts have been crawled using the data's from the contracts to analyze each block.