texts: How to print the value of encoded getter functions of contract

texts:
UPDATED: Sorry for Inconvenience, I have updated all my question and accept my apology , being naive user.

I have encoded getter functions of my contract i.e. 0x27e235e30000000000000000000000000000000000000000000000000000000000000000................ In this encoded function, there may be one, two or three arguments lets say address, string, uint. Such function may return one/two values i.e. uint/string. Now I want to call that encoded function and get its return values. which then i print them on console and also save into my array. I am trying following code, which is printing receipt of my transaction, as expected. But I want to print/save return values (returned by contract function).

try {
        await web3.eth.sendTransaction(
        {from:account1,
        to:myContAddr,
        data: myFunc
            }).then(function(res){
              console.log("Normal Getter", res);
              myResult.push(res);
          });
    } catch (error) {
      console.log(" Normal Getters: ERROR !");
    }

Should I have to decode such encoded function to extract arguments and methodID separately, and then call it ???

Note: A list of such encoded function is provided to me and also i have ABIs.


texts:
What nodes on the Ethereum network stores the entire history?

From what I understand, full nodes are only required to store the current state of the blockchain, while they are not required to store the set of transactions (history).

However, to derive current state, the history must be obtainable.

So, who stores the history and what are such nodes called (if not "full")?


texts: Best way to check you're connected to the real main net?

texts: If you're running an application which connects to a node to send and validate transactions, what is the best way to check the node is connected to the real Ethereum main net? I'm thinking of the scenario where the user of the application intentionally feeds the node a fake version of Ethereum so they can modify the state to suit there purposes or fake making the transactions to the real main net chain.


texts: How to see deployed "StandardToken" contract owner with truffle console

texts:
I have deployed on testrpc contract with ERC20 token which has following constructor:

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

contract TutorialToken is StandardToken {
    string public name = 'TutorialToken';
    string public symbol = 'TT';
    uint public decimals = 2;
    uint public INITIAL_SUPPLY = 12000;

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

My understanding is that contract will be deployed by 0th testrpc account. However when I do

TutorialToken.deployed().then(c => c.balanceOf('<0th account addr>').then(b => console.log(b)))

It displays

{ [String: '0'] s: 1, e: 0, c: [ 0 ] }

So it seems that the account has no balance. I aslo can't see the balance in "Token" tab of metamask. Looks like some other address was used to create account. However I'm not able to find any function to see who is contract creator (who was msg.sender).

Is it possible in truffle console to see who is a contract creator?

Update

The problem with balance was because of the typo: constructor name was TotorialToken instead of TutorialToken.

The original question still holds though: how to print contract owner?

Update #2

To actually see contract owner I can do something like this (thanks pabloruiz55 for suggestion):

address owner;

function TutorialToken() {
    owner = msg.sender;
    ...
}

That works. So I guess my question is different then: does OpenZeppelin's StandardToken contains owner field which can be accessed?


texts: Expected identifier, got 'eth_compileSolidity' constructor () public {

texts:
I'm unsure what identifier it is asking for, can anyone advise?

Error section

    constructor () public {
    owner = msg.sender;
}


texts: Getting the v, r, and s parameters using web3js or ethersjs

texts:
web3 documentation says that using the web3.eth.signTransaction returns the object which (inside the other object) has the r, s, and v of the message:

However, I am not getting that:

Any idea in how can I get the r, s, and v?  I want to use if to the permit function of the Dai contract


texts:
Is there any difference if I use nested functions in a contract instead of writing the code two times if the second function is a subset?

function doSmth(address user){
   transaction1;
   transaction2;
}

function doSmthElse(address user){
   transaction2;
}

vs.

function doSmth(address user){
   transaction1;
   doSmthElse();
}

function doSmthElse(address user){
   transaction2;
}

Is it going to take two blocks (double the time) to execute the complete function if it is nested? Is there a difference in gas needed?


texts: Publishing contracts with libraries using web3.py

texts:
Im trying to publish contracts with libraries in them and im getting the below issue. Contracts without libraries publish just fine. Can someone who might have faced this issue before advise what the tweak required to the code is ?

import json
import web3

from web3 import Web3, HTTPProvider

from solc import compile_source

from web3.contract import ConciseContract

with open('BurnableCrowdsaleToken_Flat_v2.sol', 'r') as myfile:
  contract_source_code = myfile.read()

compiled_sol = compile_source(contract_source_code)
contract_interface = compiled_sol['<stdin>:BurnableCrowdsaleToken']

web3 = Web3(HTTPProvider('http://localhost:8545'))

from web3.middleware import geth_poa_middleware
web3.middleware_stack.inject(geth_poa_middleware, layer=0)

contract_ = web3.eth.contract(
    abi=contract_interface['abi'],
    bytecode=contract_interface['bin'])

acct = web3.eth.account.privateKeyToAccount('myprivatekey')

construct_txn = contract_.constructor("Burnable Token","BCT","50000","18","true").buildTransaction({
    'from': acct.address,
    'nonce': web3.eth.getTransactionCount(acct.address),
    'gas': 1728712,
    'gasPrice': web3.toWei('21', 'gwei')})

signed = acct.signTransaction(construct_txn)

tx_hash = web3.eth.sendRawTransaction(signed.rawTransaction)

tx_receipt = web3.eth.waitForTransactionReceipt(tx_hash)

print (tx_receipt.contractAddress)

contract solidity here

https://gist.github.com/troowala/2860203ffb2cad3d38cd3c0301423a28

Error below

$ python3 contracts_priv.py

Traceback (most recent call last):   File "/usr/local/lib/python3.5/dist-packages/web3/utils/formatters.py", line 68, in apply_formatters_to_dict
    yield key, formatters[key](item)   File "/usr/local/lib/python3.5/dist-packages/web3/utils/normalizers.py", line 166, in normalize_bytecode
    bytecode = HexBytes(bytecode)   File "/usr/local/lib/python3.5/dist-packages/hexbytes/main.py", line 17, in
__new__
    bytesval = hexstr_if_str(to_bytes, val)   File "/usr/local/lib/python3.5/dist-packages/eth_utils/conversions.py", line 146, in hexstr_if_str
    hexstr_or_primitive, ValueError: when sending a str, it must be a hex string.

Got: '6060604052.....be907dd5250029'

Traceback (most recent call last):   File "contracts_priv.py", line 28, in <module>
    bytecode=contract_interface['bin'])   File "/usr/local/lib/python3.5/dist-packages/web3/eth.py", line 367, in contract
    ContractFactory = ContractFactoryClass.factory(self.web3, **kwargs)   File "/usr/local/lib/python3.5/dist-packages/web3/contract.py", line 265, in factory
    normalizers=normalizers)   File "/usr/local/lib/python3.5/dist-packages/web3/utils/datatypes.py", line 33, in __new__
    namespace)   File "cytoolz/functoolz.pyx", line 232, in cytoolz.functoolz.curry.__call__   File "/usr/local/lib/python3.5/dist-packages/eth_utils/functional.py", line 22, in inner
    return callback(fn(*args, **kwargs))   File "/usr/local/lib/python3.5/dist-packages/web3/utils/formatters.py", line 70, in apply_formatters_to_dict
    raise type(exc)("Could not format value %r as field %r" % (item, key)) from exc ValueError: Could not format value '6060604052600....907dd5250029' as field 'bytecode'


texts: How to send a lot of transactions to ethereum, using js

texts:
I'm trying to send a lot of transactions to Ethereum with one program written in js. I use node js, web3 and infura ropsten. The problem is: if i send transactions at once, most of them just disappear. Trying to solve this problem, i send transactions with intervals. It works, but very slowly. I spend hour to send only 100 transactions. Is there any solution how to make it work faster and right? I was thinking about sending transaction after previous one starts pending, but I don't see how can I do that. Function sendRaw gets transaction number only after some time. This code reads the file, gets address, amount and optional data and uses method of smart contract to transfer tokens.
Here is code:

function sendRaw(rawTx) {
var privateKey = new Buffer(key, 'hex');
var transaction = new tx(rawTx);
transaction.sign(privateKey);
var serializedTx = transaction.serialize().toString('hex');
web3.eth.sendRawTransaction(
'0x' + serializedTx, function(err, result) {
    if(err) {
        console.log(err);
    } else {

        console.log(result);
        Ntrans=result;
    }
});
}

var nonce = web3.eth.getTransactionCount(address);
var gasPrice = web3.eth.gasPrice;
var gasLimit = 90000;

var fs = require("fs");
var buf1 = new Buffer(1024);
var buf2 = new Buffer(1024);
var buf3 = new Buffer(1024);
var i = 0;
var j = 0;
var k = 0;

var fd = fs.openSync('/home/kate/Desktop/file.txt', 'r+');

function recurs()
{
    if(k==5) return -1;
    j = 0;
    do
    {
          fs.readSync(fd, buf1, j, 1, i);
          i++;
          j++;
    }
    while(buf1[j-1] != 32);
    AddressC = String(buf1.slice(0, j-1))
    console.log(AddressC);
    j = 0;
    do
    {
          fs.readSync(fd, buf2, j, 1, i)
          i++;
          j++;
    }
    while(buf2[j-1]!=32);
    ValueT = Number(buf2.slice(0, j-1))
    console.log(ValueT);
    j = 0;
    do
    {
          fs.readSync(fd, buf3, j, 1, i);
          i++;
          j++;
    }
    while(buf3[j-1]!=10);
    TxC = String(buf3.slice(0, j-1));

    txOptions =
    {
         nonce: web3.toHex(nonce),
         gasLimit: web3.toHex(gasLimit),
         gasPrice: web3.toHex(gasPrice),
         to: contractAddress

    }

    console.log(TxC);
    console.log(txOptions);
    rawTx = txutils.functionTx(interface, 'foreignBuy', [AddressC,
    ValueT, TxC], txOptions);
    sendRaw(rawTx);
    k++;
    nonce++;
   /* while(web3.eth.getTransactionReceipt(Ntrans)=="null")
    {

    } */
}

setTimeout(function(){
    recurs();
}, 5000);
}
recurs();


texts: Cannot send ETH or DAO via Ethereum Wallet (Mist)

texts: I have DAO and ETH in my Ethereum Wallet. Every time I try to send it, I input my password and press send, and it sits there saying "confirming" for a few minutes. Eventually, it just reverts back to the password entry portion without doing anything, as though I never entered my password and pressed send. Also, it says can't estimate gas as you need 1 eth in your wallet. I have more than 1 ETH in my wallet. When I close the sending window, I get "transaction denied." Please help.


texts:
I'm having a problem on a new ethereum install on a Mac:

Fatal: Error starting protocol stack: listen udp :30303: bind: address already in use

Any suggestions to fix would be greatly appreciated.


texts: Ethminer Error: Dag generation failure: Invalid Argument

texts: I have been mining for a while now. I restarted my computer this evening and I have been receiving the error " DAG Generation Failure. Reason: Invalid argument" when running the same bat file I always do. I have not made any changes to my system.


texts:
I just scanned the PC using MBAM and it detected the ZIP file of ethminer (only the zip, not the extracted folder) as malware.
Now, after used MBAM to delete the zip, suddenly the ethminer itself won't work! (huh?!) -It created a new DAG file after the restart! I didn't touch the ethminer files in the extracted folder, but from some reason it stopped working, and created a new DAG suddenly.. ?
What is going on?

Also, I downloaded ethminer from here:

Ethminer from a certain blog

And realized that there is a completely different download on the GitHub page!? as can be seen here:
Ethminer from GitHub


texts: Can I sell a portion of my DAO tokens on a market place?

texts: If I bought all my DAO tokens with the same account, will I be able to sell only a portion of them on a marketplace?


texts: How would a simple function, which when called, automatically distributes tokens to all whitelisted users of a mapping look like?


texts: Error: Transaction:exited with an error (status 0) after consuming all gas

texts:
New to Ethereum and learning unit testing with Truffle. Here in smart contract function;

function createAgreement(
        bytes32 _id,
        address _owner,
        string _fileHash,
        address[] _listOfSigners,
        uint256[] _types
    )   public returns (bool success) {
        //TODO: code here
        return true;
}

Here is the test cases that I wrote so far:

let owner = web3.eth.accounts[1],
    fileHash = "2413FB3709B05939F04CF2E92F7D0897FC2596F9AD0B8A9EA855C7BFEBAAE892",
    listOfSigner = ["0xC5fdf4076b8F3A5357c5E395ab970B5B54098Fef",
                    "0x821aEa9a577a9b44299B9c15c88cf3087F3b5544"],
    types = [0,1,2],
    Instance;
    id = "XVXIJLO-9XNQ-ZQWF-OLAF-E14L09FHZALQ";

describe("Unit Test For Create Agreement Method", function() {
    it("Adding agreement into blockchain", function(){
        return Instance.createAgreement.call(id, owner, fileHash, listOfSigner, types)
            .then(function(res){
                console.log("created!");
            });
    });
});

When I run the test case, it's getting failed with an error of:

  Error: Transaction:
  0xc5bbcab6c3cc45cf198e5cd75725c881eb280f3b6758b9f080101c7d491985dd
  exited with an error (status 0) after consuming all gas. Please check
  that the transaction:
      - satisfies all conditions set by Solidity assert statements.
      - has enough gas to execute the full transaction.
      - does not trigger an invalid opcode by other means (ex: accessing an array out of bounds).

Probably, error due to GAS, how could estimate GAS and pass it?


texts:
Using instructions from here I have a local private Ethereum blockchain running in a distributed envoirnment as per the diagram below:
|---------|   Blockchain Node (192.168.122.111) |---------|
|---------|   Processor Node (192.168.122.222) |---------|
Blockchain Node -  geth terminal is running here.
Processor Node - does some calculations and write to the Blockchain Node where geth terminal is running. A web3.py script is running here which sends contract deployment request to the blockchain node.
These two nodes are in the same network, and can ping each other. Also I have tried file transfer with Python and its working perfectly.
My problem is: When I try to connected from the Processor Node to the Blockchain Node through this code unable to connect. Please help where I am making mistake?
w3 = Web3(http://192.168.122.111:30000)
account = Account()
acct = account.privateKeyToAccount(private_key_of_Processing_Node) // also tried with private key of Blockchain node
EDIT
Error: Could not discover provider while making request: method:eth_chainId
Also I am using following command to connect to geth on the blockchain node
 geth --port 3000 --networkid 58343 --datadir=./eth-blockchain --maxpeers=5 --rpc --rpcport 8543 --rpcaddr 192.168.122.111 --rpccorsdomain "*" --rpcapi "eth,net,web3,personal,miner" console 2>>eth.log


texts: Is there a complete list of available values for the `--rpcapi` command line option of geth?

texts: I known this page https://github.com/ethereum/wiki/wiki/JSON-RPC, but seems it doesn't contains all available apis, for example, it doesn't contain personal API.


texts: How to verify a paper wallet is working without compromising the private key?

texts:
MyEtherWallet tells the user:

  You need to back up your private keys externally and verify you can access the wallets.

I am wondering, how do you verify you can access the accounts without compromising (e.g., importing into geth) the private keys on the cold storage?


texts:
I've been syncing the ethereum blockchain for over a week now and it has stopped downloading blocks but continues to download structure. When I restart it, it resumes downloading blocks but will only get to within 50 blocks, of the nearly 4 million, before stopping again. at this point I am at 5,731,656 of 5,731,668 of chain structure.

Does this chain structure have anything to do with completing the
download and if so how high does it go?
Should I keep restarting it and hope it eventually completes the last
few blocks or wait for a given number of coin structure to complete
?


texts: cpp-ethereum (Homestead) starts resyncing blockchain

texts:
I just installed cpp-ethereum 1.2.2 in order to upgrade to Homestead. When eth is started it begins to re-sync the blockchain from block 1, while the whole blockchain is already on my machine.
Is this necessary?
Is there a way to reuse the blockchain already present in .ethereum/chaindata?


texts:
I am trying to deploy my contracts with the specific account the user is using instead of hard coding it. But in this code, I get an error as such:

Error: Cannot find module 'web3'

the truffle-config.js file is as follows:

const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:7545'));
var acc;
web3.eth.getCoinbase(function(err, account) {
      if (err === null) {
        acc=account;
      }
    })

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*", // Match any network id
      from: acc
    },
    develop: {
      port: 8545
    }
  }
};

How to overcome this error?


texts: How to purchase ETH at one of the top ETH exchanges (for Singapore residents)?

texts:
I'm based in Singapore and would like to know the options I have for buying Ethereum.

We don't have a local ETH exchange, but there's a BTC exchange called FYBSG. I suppose I can do Singapore Dollar to BTC conversion on FYBSG, transfer the BTC to Poloniux etc and convert to ETH there, but it seems inefficient and costly.

Any other ways to purchase ETH at one of the top ETH exchanges when you are a Singapore resident?


texts:
I'm interested in reading how dHedge implemented their asset-buying program so would greatly appreciate if you guys could help me decode their json abi. I couldn't find a json abi decoder anywhere as the github web3 library says it hasn't implemented json abi decoding yet.
Any help is appreciated
Edit: I forgot to include the link
https://docs.dhedge.org/dhedge-protocol/contract-details


texts: Invalid Address format - Etherscan.io APIs problem

texts:
I have download list of verified open source contract addresses's list and loaded into addresses[]. Now I want to download sourcecode/ABIs etc... of that contracts. Although, i have called setTimeOut between each API call to avoid excessive calls, but still could not be succeeded.

Here is my code; . If i download one contract, then this code has no problem

const jsdom = require("jsdom");
const { window } = new jsdom.JSDOM(`...`);
var $ = require("jquery")(window);

var data = fs.readFileSync('./osContracts/list.csv', 'utf8');

myJData = csvToJSON(data);

var addresses = [];

for(i=0; i<myJData.length-1; i++)
{
addresses[i] = myJData[i].ContractAddress;
}

for(i=0; i<addresses.length; i++){
  setTimeout(function() {
    $.getJSON('https://api.etherscan.io/api?module=contract&action=getsourcecode&address='+addresses[i]+'&apikey=QTUXRX1X2T.....', function (adData) {
    console.log(adData.result)
        });
    }, 5500 * i)

}

Here is my error:

Invalid Address format
Invalid Address format
Invalid Address format..........................................

UPDATE:
the value of addresses

[
  '0x2699fc3753b1036534feb3be8704c9c5e3262606',
  '0x5a3b8896d90bf4e656d35370d6b2ab9613a854d1',
  '0xb215bf00e18825667f696833d13368092cf62e66',
  '0x213a22d873e02269ac45c094c0655a09eaa22c3a',
  '0x67d764d948408a4f01dec1623c4a42275acddb24',

...2979 more items
]

and i can get the the result with their values, but only for one contract
UPDATE1.
One Contract means... anyone from my addresses[].... not only one...


texts: Internal transactions totaling 100+ Ether flowing into a wallet

texts:
When you look at the wallet address below, it has a balance over 100 ETH but there are no inflows in the etherscan ledger to show where those funds came from

https://etherscan.io/address/0x4adf0dbc8bb29a61be114c22879202a76790c9d9

Clicking on the etherscan tab called "Internal Transactions" instead, we finally do see the source of inflows, mostly coming from an Ethereum Contract, not another wallet.

https://etherscan.io/address/0x4adf0dbc8bb29a61be114c22879202a76790c9d9#internaltx

Any guesses as to what in the hell type of a contract is paying out 40+ Ether at a time upon request, the type of contract interaction probably being invoked by the wallet holder, and why?


texts: for Mac - Importing priv key / wallet of receiving DGD address into Mist

texts:
I've followed the instructions below but am getting an error message in terminal geth command not found

Open TextEdit
Paste key into TextEdit without any extra characters or quotations
Save the file as nothing_special_delete_me.txt to your Desktop
Open Terminal, run command:

geth account import ~/Desktop/nothing_special_delete_me.txt

When I paste the key do I include the letters UTC?


texts:
I'm using geth's traceTransaction() API to index certain opcodes that are used in transactions. When I request traces from some transactions (e.g. 0x36351fcbe7497e38f9036505498b0b76dd715294cc4b9aec1c4bc30a8193f05d) the memory usage becomes absolutely insane. I'm talking "crashing a 256 GB RAM server"-insane.

Is this a bug? Am I doing something wrong?


texts: Why are all NFTs created from Null Address on Opensea?

texts: When someone mints on NFT on OpenSea using their own wallet as the identity of the creator, why does Null Address always appear in the NFT's transaction history as the creator instead? and then the second event in the history says Null Address transfers the NFT to the creator


texts: Python keccak256 hash of uint8 array not matching solidity hash?

texts:
I have a function in a smart contract:

  function getNumberHash(uint8[] _numbers) constant public returns (bytes32) {
    return keccak256(_numbers);
}

When I pass [1,2,3,4,5] as the argument it returns:

"0": "bytes32: 0x5917e5a395fb9b454434de59651d36822a9e29c5ec57474df3e67937b969460c"

I have this Python script but it returns a different hash:

import sha3
import numpy as np

a = np.array([1, 2, 3, 4, 5], dtype=np.uint8)

k = sha3.keccak_256()
k.update(a)
print(k.hexdigest())

Which returns the following hash:

0x7d87c5ea75f7378bb701e404c50639161af3eff66293e9f375b5f17eb50476f4

Why aren't the two functions returning the same value since they are both uint8[] and using the same keccak256 algorithm? How can I resolve this issue?


texts: What caused this error: Attempting to run transaction which calls a contract function, but recipient address is not a contract address

texts:
I have a contract and a set of mocha tests. I recently switched from using the ethereum client that comes with truffle (the one you get when you run truffle develop) to the ganache-cli. Somehow, in switching back and forth between them, I caused my tests to fail to run, and migrations don't seem to work either. The migrations work when I'm connected to ganache, but not the truffle development client. Here's the full error message.

$ truffle migrate --reset
Using network 'development'.

Running migration: 1_initial_migration.js
  Replacing Migrations...
  ... 0x9391ac92dfbf86306e9ed896e7f9d5d45d9d88a072323ca1ef116f242ae0d2be
  Migrations: 0x8cdaf0cd259887258bc13a92c0a6da92698644c0
Saving successful migration to network...
  ... undefined
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Attempting to run transaction which calls a contract function, but recipient address 0x8f0483125fcb9aaaefa9209d8e9d7b9c8b9fb90f is not a contract address
    at Object.InvalidResponse (/home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:38:1)
    at /home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:86:1
    at /home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/truffle-migrate/index.js:225:1
    at /home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:134:1
    at XMLHttpRequest.request.onreadystatechange (/home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1)
    at XMLHttpRequest._setReadyState (/home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1)
    at XMLHttpRequest._onHttpResponseEnd (/home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1)
    at IncomingMessage.<anonymous> (/home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:469:1)
    at IncomingMessage.emit (events.js:132:15)
    at endReadableNT (_stream_readable.js:1101:12)
    at process._tickCallback (internal/process/next_tick.js:152:19)

I can find plenty of issues and SE questions for "Error encountered, bailing. Network state unknown. Review successful transactions manually." But the line after that is always different than mine. I can't seem to find any google results for "Attempting to run transaction which calls a contract function, but recipient address" is not a contract address

The message makes sense to me, but how could that not be a contract address?

ETA: I also upgraded from truffle 4.0.5 to truffle 4.1.0, which is probably what caused the problem.


texts: Why don't private blockchain networks that do not charge for transactions charge a fee when processing ethereum/ proprietary token on the network?

texts: I ask this questions is there seem to be 2 flavors of blockchain: 1. Public think bitcoin and ethereum. 2. Private hyperledger, SAP Leonaro, etc. The public network charges for transactions which make it popular with the public. The private network does not charge for transactions which is why it is popular with businesses. Why is there no network that can do both? For example eosio | Blockchain software architecture  is trying to make it cheaper to process transactions which I assume is meant to appeal to businesses and consumers. Why cannot a private blockchain such as Hyperledger Sawtooth/ Fabric which are private be free for businesses to use because businesses validate transactions but also accept a token which has value and when a consumer users the token to purchase an item from a business in the network either charge a fee for validating the transaction or do not charge for it.


texts:
I started mining on a regular laptop to understand a few things, before I move on to a more serious machine.

I followed the instructions as shown here: How to Mine Ether and use Ethereum on Windows?

And I currently have these 2 windows running in parellel:

Also, at the beginning when I only start geth --rpc it shows Accounts: [0].
Does it mean that mining is actually working and connected to account '0'? (The only account I created?)

I am asking this because setting all of these up took only a short time, and it made me wonder maybe if it was too easy to set it up (Installing Geth, creating Geth account, running a node and installing Ethminer), then maybe something is wrong and it's not really working, but just showing some pretty running CMD code that looks like it's taken from a cool movie?


texts:
I was looking through some code and tried to understand some of the lines of code. I notice it uses .div(integer). Here is the snippet
passengers[passenger].insuranceAmountForFlight[flightKey] = insuranceAmount.div(2) + insuranceAmount;

what does .div() do here?
Thank you


texts:
I ran Claymore's eth miner for 8 hours and got 200 shares. I set my eth address when I ran the miner, but no eth was deposited to my address. When I restarted the miner the shares were reset to 0.

When will I get eth? How do I know if I'm mining right? Are my shares saved?

Edit: I'm not sure which pool I used earlier. I'm looking for a pool now. What happens when I set the pool and mine. How many shares do I need to get eth? If I stop the miner are all my shares lost?

This is my config.txt

-epool ?
-ewal 0x8A9cxxxxxxxxxxxxxxxxxxx
-epsw x
-dpool ?stratum+tcp://yiimp.ccminer.org:4252
-dwal DsUt9QagrYLvSkJHXCvhfiZHKafVtzd7Sq4
-dpsw x
-esm 1
-mode 0
-tt 70
-asm 0


texts: Eth or USD values of token transfers/transactions

texts: Is there any way to retrieve the eth or dollar amount of a Transaction Like etherscan shows on their Website when clicking on a Transaction? Are they pulling price data of the transferred tokens the moment a new transaction comes in and store it, or how is that to Archive? If its the only way using exchange Data, what exchange has all the erc20 token prices? I cant think of any but etherscan has a dollar value on every transaction no matter how unknown the tokens are.


texts: Can there be multiple transactions with the same nonce and from address?

texts: I am trying to create a state-channel by signing transactions directly, and I was wondering that the nonce might be troubling in this case.


texts: Usdc bep20 from trust wallet sent to usdc erc20 on metamask

texts: Please, I sent a bep20 usdc from my trust wallet account to an erc20 usdc or something like that on my metamask account since almost 24hr, but it's yet to reflect. Can someone kindly help with some guides, please?


texts: How to access in JavaScript multiple return values returned from a solidity function

texts:
My contract function returns two values. How to access the multiple return values in JavaScript from a mocha testcase?

contract X {
   function a() pure public returns(uint,uint) {
       uint p=10;
       uint q=20;

       uint add = p+q;
       uint sub = q-p;

       return(add,sub);
   }
}


texts: Minimum system requirements for mining ropsten ethers

texts:
I want to create my own faucet that will mine Ropsten ethers.

What is the minimum system configuration which is required? Is it a good idea to use my own server such as AWS? What will be the tentative cost? Can it be done with free tier AWS?

What else do I need to keep in mind when mining rETHs?


texts: Send ether to contract address in web3.js

texts:
I want to send ether to this contract's contribute function using web3.js

I'm trying below code for the same but this doesn't work for me.

var AbiOfContract = 'abi_code';
var contractAddress = "0x8bbc*************************";
var contract1 = web3.eth.contract(JSON.parse(AbiOfContract)).at(contractAddress);

contract1.contribute({"to": contractAddress ,"from": accounts[1], "value": web3.toWei("10.0", "ether")},"password");

contract CrowdFunder {

    function contribute()
    public
    inState(State.Fundraising) payable returns (uint256)
    {
        contributions.push(
            Contribution({
                amount: msg.value,
                contributor: msg.sender
                })
            );
        totalRaised += msg.value;
        currentBalance = totalRaised;
        LogFundingReceived(msg.sender, msg.value, totalRaised);
        checkIfFundingCompleteOrExpired();
        return contributions.length - 1;
    }
}

Any help regarding this will be highly appreciated.


texts: bsc get transaction list by address Web3 (realtime,socket)

texts:
How can I track transactions of a wallet in the bsc network instantly? (I am thinking of using web3 js.)
I don't want to do it with the api on BSCscan. As far as I know, it does not show it instantly.


texts:
How to generate ethereum address derived from xpub in PHP?

I am trying to generate ethereum address similar like below link does for bitcoin.

https://github.com/blockchain/receive-payments-demos

I want to use one xpub and generate multiple ethereum addresses.

Thanks in advance.


texts: How to confirm a transaction through Merkel root in this block

texts: As shown above, how to get those blue hash values and how do I determine which few hashes I need


texts: Deploy smart contract to Ether scan network

texts:
I am trying to make a sample smart contract and migrate to ether scan explorer but not able to deploy. I am using truffle, infura and metamask to test my application. i am able to compile it successfully but when i try to run migrate it says everything is upto date, nothing to compile. My truffle.js file looks like this

    ropsten: {
      provider: function (){
        return new HDWalletProvider(mnemonic,
        'https://ropsten.infura.io/v3/api_key')
      },
      network_id: 3,
      from: 'address',
      gasPrice: 25000000000000
    }
}


texts: How to send raw transaction if I don't have private Key but I know my password?

texts:
I am doing raw transaction to send token from one account to another. But I don't have private key of my account but i do have the password. How can I send raw transaction using my password only. Here is my code:

var Tx = require('ethereumjs-tx')
var Web3 = require('web3');
var web3 = new Web3(new
Web3.providers.HttpProvider('https://rinkeby.infura.io/infurakey'));
var Personal = require('web3-eth-personal')
var personal = new Personal(Personal.givenProvider)

var ABI =[{"constant":true,......","type":"event"}]

var contract =new web3.eth.Contract(ABI, '0x9...5bf3f4f')

const account1 = "0xd94acc...5071240364364c86f45";
const account2 = "0xf7689d04139...ad668CBF2Af2D29";

web3.eth.getTransactionCount(account1,(err, txCount)=>{
const txObject ={
from: account1,
nonce : web3.utils.toHex(txCount),
gasLimit: web3.utils.toHex(800000),
gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei')),
to: '0x9...a42255bf3f4f',
data: contract.methods.transfer(account2, 1000).encodeABI()
 }
 var password = new Buffer("mypassword", 'hex');
 const tx = new Tx(txObject)

tx.sign(password);
const serializedTransaction = tx.serialize();

const raw = '0x' + serializedTransaction.toString('hex')
web3.eth.sendSignedTransaction(raw, (err, txHash)=> {
    console.log('err:', err, 'txHash:', txHash)
  })
})

I am getting error:

RangeError: private key length is invalid


texts:
I'm trying to start Geth from an offline machine. An answer in a related question seems to indicate this is possible.

However, running the command $ geth hangs at Starting Server. Trying to attach an IPC console via geth attach fails, complaining about a missing geth.ipc file. Attempting to pass in one-off commands via console hangs as well.

I'm getting the feeling a network connection is needed for Geth to complete its bootstrapping process. Has this been the case for others, or should Geth be able to start offline?

I'm running Ubuntu 14.04 and Geth 1.4.0-unstable.


texts: How to deploy truffle project on web server?

texts:
I've developed a DApp using truffle suite and now I want to deploy this dapp online so that everyone will be able to access it over the internet.

I've used Rinkeby-Testnet for smart contract deployment.  Whenever I use npm run dev command, it deploy the frontend of dapp on locally using lite-server but, now I want to publish it globally and have no idea about it.

Please help me !!!


texts:
If I have a public state variable, does this mean that other contracts can access or even change its value?

I have made a cryptocoin from here and all variables are declared as public, so I am concerned if other contracts can only view these variables or can they change the values too?


texts: web3.personal.unlockAccount creates too many nodejs defunct processes

texts:
I am getting a lot of [nodejs] [defunct] process when run this code. Is there a way to check if an account is already unlocked or lock the account to properly close the nodejs process it starts so that there are not too many nodejs defunct processes.

const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
let txHashArray = [];

try {
    if (web3.isConnected()) {

        const abi = '[{"constant":false,"inputs":[{"name":"_int","type":"uint16"}],"name":"set","outputs":[{"name":"arrayLength","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"length","outputs":[{"name":"arrayLength","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}]';
        const contract = web3.eth.contract(JSON.parse(abi));
        const contractAddress = '0x4D0f2e99a871A276da395538C8107275C17bCe12';
        contractInstance = contract.at();

        for (let i = 0; i < 1000; i++) {
            web3.personal.unlockAccount(web3Config.defaultAccount,
                web3Config.defaultAccountPwd);
            /*

            const txHash = contractInstance.set(i,{from:web3Config.defaultAccount, gas:'9040000', gasPrice:'0'});

            txHashArray.push(txHash);
            */

            console.log(i)
        }
        /*
        // Write txHash to file to check later
        var txfile = fs.createWriteStream('txfile.csv');
        txfile.on('error', function(err) { /* error handling */ });
        txHashArray.forEach(function(v) {
            txfile.write(v + '\n');
        });
        txfile.end();
        */

    } else {
        console.log('web3 is not connected');
    }
} catch (error) {
    console.error(error);
}


texts: Can you interact with a contract by only looking at its bytecode?

texts:
Suppose you don't have the source of a contract, but have its bytecode. Can you theoretically interact with it somehow, or see what it does, by only looking at its bytecode?

Can functionality be obscured, or can you deduce everything that a contract does by its bytecode alone?


texts:
I'm encountering a problem related to the gas (I guess).

Please note that I'm using the proxy pattern for upgradeable smart contracts: CODE EXAMPLE HERE - Explanation from Openzeppelin

I'm trying to call the function initialize defined in a logic contract:

/* NOT WORKING EXAMPLE */
function initialize(address superAddress) public {
    require(!_initialized, 'Contract already initialized');
    _ownerAddress = superAddress;
    _ceoAddress = superAddress;
    _cfoAddress = superAddress;
    _cooAddress = superAddress;

    _initialized = true;
}

When I'm calling initialize I'm getting the error:
    Error: "Returned error: VM Exception while processing transaction: revert"

And this is the related log:

 [08:53:32] eth_sendTransaction
 [08:53:32]   Transaction: 0x7a46396621502cb541f0509ff975fb9695b15d4efd9a5d7c27b320755066a37f
 [08:53:32]   Gas usage: 88988
 [08:53:32]   Block Number: 245
 [08:53:32]   Block Time: Tue Oct 01 2019 08:53:32 GMT+0200 (W. Europe Summer Time)
 [08:53:32]   Runtime Error: revert
 [08:53:32] eth_getBlockByNumber

But, when I'm commenting a couple of assignments in the initialize function (like below) everything is working:

/* WORKING EXAMPLE */
function initialize(address superAddress) public {
    require(!_initialized, 'Contract already initialized');
    _ownerAddress = superAddress;
    _ceoAddress = superAddress;
    /* _cfoAddress = superAddress; */
    /* _cooAddress = superAddress; */

    _initialized = true;
}

Below an example of the call of initialize function on the client side:

contractInst.methods.initialize('0x4F9aA950b153a3D27a4f6ed738f6Ce7D4dc8cA7e').send({})
    .then(resp => console.log(resp))
    .catch(e => console.error(e));

Do you have any clue of the causes of that error? And how to solve it?

Extra notes:
I'm using GANACHE and the smart contracts are developed with solidity ^0.5.0;

THANKS!


texts: How can a raw transaction be generated with pyethereum library?

texts:
Is it possible to generate a raw transaction using pyethereum library taking inputs wallet json, password, along with transaction parameters?

My attempt below, I get the hex, when inputting hex into MyEtherWallet send from offline, it recognizes the amount and target address, but then gives 'Invalid format'.   Hoping for a suggestion to debug this.  Thanks!

from ethereum import transactions, utils
from ethereum.tools.keys import decode_keystore_json
import rlp,json

def genTransactionHex(target,nonce,wallet_json,amount = 0, gasprice = 24000000000, startgas=21000):

    priv_key = decode_keystore_json(wallet_json, raw_input("decode wallet:"))

    #[nonce, gasprice, startgas, to, value, data, v, r, s]
    tx = transactions.Transaction(nonce, gasprice, startgas, target, amount, "").sign(priv_key)
    return rlp.encode(tx).encode('hex')

with open('wallet.json') as wallet_data:
    wallet = json.load(wallet_data)

target = '0x67e5d173BE803Ca97687498CD3F892BFaB54d12C'
res=genTransactionHex(target, 0, wallet, 10000000000)

[EDIT] here is an example hex:
[removed]

[EDIT2]  Tried this on etherscan , and it worked!  Not sure why it wasn't going through on MyEtherWallet.


texts:
so I have a function getPriceReserveBuySUForEth that is returning the incorrect value and I'm not sure why :|
I guess what the function does and the purpose doesn't really matter so I won't waste the space here
The function:

function getPriceReserveBuySUForEth(uint256 _value) public view returns (uint256) {
    require(getAvailableReserveUSD(0) > 0);                     // Need to have some reserve available in order to buy SU back

    uint256 maxReserveAvailable = address(this).balance * getEthPrice() * percentDropBeforeBonds / 100;
    uint256 m = 2 * maxReserveAvailable / ((maxReservePriceDeviationInCents * 10**24)**2);
    uint256 amountReserveUsedUp = maxReserveAvailable - uint(getAvailableReserveUSD(0));
    uint256 averageTradePrice = sqrt(2 * (amountReserveUsedUp + _value) / m);
    uint256 tempVal = 10**26 - averageTradePrice;
    return tempVal;
}

When using 0 as the input, it sgould return 10^26, however it returns 0.

averageTradePrice should = 0. Therefore 10^26 - 0 should = 10^26.
I tested this with a function y:

function y(uint256 _value) public view returns (uint256) {
    return 10**26 - 0;
} // I know _value doesn't do anything here - I was just lazy in copy/pasting

This correctly returns 10^26.
Also I created a function x to test that averageTradePrice does indeed = 0:

function x(uint256 _value) public view returns (uint256) {
    require(getAvailableReserveUSD(0) > 0);                     // Need to have some reserve available in order to buy SU back

    uint256 maxReserveAvailable = address(this).balance * getEthPrice() * percentDropBeforeBonds / 100;
    uint256 m = 2 * maxReserveAvailable / ((maxReservePriceDeviationInCents * 10**24)**2);
    uint256 amountReserveUsedUp = maxReserveAvailable - uint(getAvailableReserveUSD(0));
    return sqrt(2 * (amountReserveUsedUp + _value) / m);
}

This is the exact same function as getPriceReserveBuySUForEth, except it returns the value for averageTradePrice instead of 20^26 - averageTradePrice. x(0) does indeed return 0 like it should.
So why does getPriceReserveBuySUForEth return 0 when it should return 10^26??


texts:
I have an ethereum consortium blockchain based on Azure.
I've been experimenting with an application which has a very simple smart contract, but may be data intensive(?).

The contracts itself, stores data that comes from the Javascript console (it's basically a mappping that maps to a structure of several strings).

This has never happened before, so I was wondering if the issue would be the amount of times the geth loadscript command is invoked or the amount of data in each interaction (perhaps strings are too expensive?). I have however increased the genesis.json gas limit very much and each transaction has sufficient gas.

My issue happens after interacting with the contracts a few times. The miner nodes keep mining blocks, but my transactions ceased to be mined (even transfers between the main account to a new account).
After a day or so, the transactions are mined, and the data structure is populated.

Either way, any feedback or request for additional information are much apprecieated,

Thanks


texts: truffle test - does not Assert (Erc20, Solidity)

texts:
I am probably doing something wrong but can't see what exactly.

Code:

pragma solidity ^0.5.8;

import "truffle/Assert.sol";

contract TestABC {
    function totalSupplyTest() public {
        bool a = true;
        bool b = true;
        Assert.equal(a, b, "message ABC");
    }
}

Command:

$ truffle test

Result:

Using network 'development'.

Compiling your contracts...
===========================
> Compiling ./test/TestABC.sol

  0 passing (3ms)

The expected output should say:

  1 passing (... ms)


texts: Sending Token when the contract receives some value

texts:
I'm trying to make sure that, when my contract receives any token, send mine to the wallet of the person who sent it to the contract.
event Received(address, uint);
    receive() external payable {
    emit Received(msg.sender, msg.value);
    uint256 numTokens = msg.value * 1000;
    require(numTokens <= balances[msg.sender]);
    balances[address(this)] = balances[address(this)].sub(numTokens);
    balances[msg.sender] = balances[msg.sender].add(numTokens);
    emit Transfer(address(this), msg.sender,  numTokens);
}

I'm doing this, but an error appears:
Warning! Error encountered during contract execution [out of gas]
Transaction Details
What I find strange is that if I remove the line:
balances[msg.sender] = balances[msg.sender].add(numTokens);

The error does not happen, the quantity of the tokens in the contract decreases, but without the line I removed it does not update the wallet of who sent the tokens for the contract.


texts: Is it possible to disable "Stack too deep" errors while in development?

texts:
I know about the Stack too deep error and the workarounds for it, but I was wondering whether it's possible to disable it while in development.

Is there a pragma experimental flag for this, similar to how there is one for "ABIEncoderV2"?


texts: Unable to interact with a contract on Kovan network on Remix IDE

texts:
I am working on a project and I have successfully deployed a smart contract on Kovan test network, but for some reason, I am not able to interact with it in JS code. So, now I want to access it through remix IDE(as it has the option to do so)
How I am trying to do this:

Entering Remix
Switching to Injected Web3 option in Environment
Connecting metamask with remix
Entering the contract address in the At address field
Pressing the At address button

Nothing is happening after pressing the button.
Deployed contract address: 0xCC0F8a34B0e4ce5baac80c50E5bB1E4042dDED67, etherscanlink.
This is the contract code(mostly irrelevant to the actual problem):
contract CampaignFactory{
    address[] public deployedCampaigns;

    function createCampaign(uint minimum) public {
    }

    function getDeployedCampaigns() public view returns (address[]) {
        return [];
    }
}

I tried remix in Google Chrome and Mozilla Firefox, the same problem.
Please tell me if, this feature is available or not(interacting though deployed contracts on test networks in remix IDE)?
Suggestions?


texts:
I freshly installed the entire Ehtereum toolchain on Mac OS X El Capitan. Everything works fine. However, I cannot launch the Mix IDE. It crashes on launch.

Do you have any idea how to resolve this issue? Wallet and command line tools run fine.

Here is the log:

Process:               Mix-ide [10124]
Path:                  /Applications/Mix-ide.app/Contents/MacOS/Mix-ide
Identifier:            .
Version:               ??? (mix )
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           Mix-ide [10124]
User ID:               501

Date/Time:             2016-05-31 09:08:23.337 +0200
OS Version:            Mac OS X 10.11.5 (15F34)
Report Version:        11
Anonymous UUID:        B3D9062B-8A56-4864-6CC8-5FB4218516FA

Sleep/Wake UUID:       66B83016-BC60-4E2A-BFAF-1AC3CCB96945

Time Awake Since Boot: 26000 seconds
Time Since Wake:       4900 seconds

System Integrity Protection: enabled

Crashed Thread:        7  QThread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       EXC_I386_GPFLT
Exception Note:        EXC_CORPSE_NOTIFY


texts:
SKALE is Ethereum Dapps to run high speed, Low cost smart contract layer.

I wish to connect users to the sidechain SKALE,from their browser.
automatically without the manual change as necessary for metamask
with token attribuated in function of service utilisation


texts: How to correctly multiply signed int with unsigned int and store the result in `uint32`?

texts:
I have an int32 val that contains some negative value such as -1. I want to multiply it with a uint32 value and add a larger uint32 value  (for which I know the result will be positive) and store in uint32.

I have come up with the following solution:

uint32 result = uint32( uint32(i) * val + 100)

For example: i=-1, val=10, result should be (-1)*(10) + 100 = 90.

[Q] Is this the correct way to do it?

Since I am casting a signed int to an unsigned int as ( uint32(i) ), shouldn't a negative value (-1) get automatically converted into positive (+1) and give a result of (+1)*(10) + 100 = 110?

 pragma solidity ^0.4.6;
 contract NumTest {
    int8 i;

    function NumTest() {
      i = -1;
    }

    function number() constant returns (uint32 num) {
      uint32 val = 3;
      return uint32( uint32(i) * val + 20);
    }
}


texts: geth installation with homebrew stuck at Checking out tag v1.7.0

texts:
i am a complete newbie in the ethereum space and is trying to install geth on my mac using homebrew

after the step :
==> Cloning https://github.com/ethereum/go-ethereum.git

the process has stuck at :
==> Checking out tag v1.7.

it has been for hours and i don't know how to trouble shoot, any help would be appreciated, thank you


texts: How many nodes does Geth attempt to connect to by default?

texts: Bitcoin Core tries to connect to 8 nodes by default. How many does Geth attempt to connect to for the eth protocol (normal network gossip)? Is there a set number in the first place?


texts: Gas is purchased using Ether, does that mean I can send gas as a separate coin?


texts:
I'm looking solidity help in storing a set of strings and checking for membership in that set.  I have a concrete and an abstract question on that:

Concrete

What is the data structure in solidity that gives me a (potentially append-only) set that I can interrogate for membership?  eg, I am looking specifically for something like:

myset = ["a", "b", "c"] # registers my set on-chain
"d" in myset            # return True or False

Further, are there better or worse ways of using this data structure without a lot of data duplication?

Does the answer change if myset is a million members long?

Abstract

How is such a thing implemented under the hood?  Read access testing for membership seems possible, but since chains are immutable, how would such a list be practically updated?


texts: How does one see all tokens owned by an account?

texts: Sorry, I do not understand this very well. But with tokens (let's say those which follow ERC20), can one ethereum address own multiple tokens? How would one determine the names and balances of those tokens using JSON RPC or web3?


texts: Return a struct from a Solidity Contract

texts:
I'm just trying to get confirmation as to whether this is supported within Solidity currently.  Older responses to this question seem to imply this has been added, but I can't find any concrete literature to confirm.

If I have a struct within the contract, can I return it via a getter on the contract?  For example:

struct myDetails {
    string firstName;
    string lastName;
}

function getName() returns (???) {
    return myName;
}

Thx

Marty


texts: How to make an array of functions, and how to call it

texts:
this:

    mapping(uint => function()) funcMap;

doesn't give any error in Remix.

But I don't know how to call it:

pragma solidity ^0.5.2;
contract b {
    mapping(uint => function()) funcMap;
    function g() public view {
        uint x=0;
    }
    function update() public {
        funcMap[1] = g();
    }

this line

        funcMap[1] = g();

gives this error:

browser/Playground.sol:14:22: TypeError: Type tuple() is not implicitly convertible to expected type function ().
    funcMap[1] = g();
                 ^-^


texts: Where is wrong cause "Gas limit set dangerously high"?

texts:
Problem:

My smart contract sendTo function send ETH to payee. Whenever I use Metamask to send some ETH to payee it shows "Gas limit set dangerously high", even I comment out "isOwner" .

Smart Contract

contract Payment {

    event PaymentLogger(
      address _payee,
      uint _amount,
      uint _payeeValue
      );

    // address private _owner;

    // modifier isOwner {
    //     require(_owner == msg.sender);
    //     _;
    // }

    // function Payment() internal {
    //     _owner = msg.sender;
    // }

    function sendTo(address _payee, uint _amount) public payable {
      require(msg.value >= _amount);
      _payee.transfer(_amount);
      PaymentLogger(_payee,_amount,msg.value);
    }
}

Web3js

   $("#sendToButton").click(function() {
        heavengame.sendTo($("#payee").val(), web3.toWei($("#amount").val(),'ether'), (err, res) => {
            if (err) {
                $("#loader").hide();
                console.log(err, result);
            }
        });
    });

Correct code

$("#sendToButton").click(function() {
    heavengame.sendTo($("#payee").val(), web3.toWei($("#amount").val(),'ether'), {value: web3.toWei($("#amount").val(),'ether'), gas: 1000000},(err, result) => {
        if (err) {
            console.log(err);
        }
    });
});


texts:
I have understood how bitcoin works (coinbase block, mining, links between transactions, hashrate, nounce, proof of work, ...)
Now i want to understand how Ethereum works.
Can we say it is the same concept than bitcoin but extended with smart contracts ?
Or is it something radically different ?
Basically i want to know if there are a maximum amount of ETH that will be forged each time a new block is mined ?
Thanks


texts: What is the most efficient way to map two different key types to a struct?

texts:
In the code here, I have created a new Customer called "mcycleowner", and mapped it to an input _address.  However, I also want to map it to the input _license so that customer info can be queried with either an Eth address or license plate number.

To do so, I created a new Customer "mcyclelicenses", and the function addLicense takes the same inputs as newMcycleOwner (except address), only this Customer is mapped to _license.  This function is triggered within the "newMcycleOwner" function so that both customers and mappings are created simultaneously.

However, doing it this way means having two records of each customer's information, which seems like it would be a waste of space, and also whenever customer info needs to be changed, it will have to be changed in two places.  Is there a better way to do this?

// < ---------------------- MOTORCYLCES ---------------------- >

mapping (address => Customer) mcycleowners;
address[] public mcycleownerAdds;

function newMcycleOwner(address _address, string _custname, string _color, string _make, uint32 _year, string _license) onlyMember public {

    Customer storage mcycleowner = mcycleowners[_address];
        mcycleowner.custname = _custname;
        mcycleowner.color = _color;
        mcycleowner.make = _make;
        mcycleowner.year = _year;
        mcycleowner.license = _license;

        mcycleownerAdds.push(_address);

    addLicense(_custname, _color, _make, _year, _license);
}

    function getMcycleAdds() public view returns(address[]) {
        return mcycleownerAdds;
    }

    function getMcycleByAdd(address _address) public view returns(string, string) {
        return (mcycleowners[_address].custname, mcycleowners[_address].license);
    }

    function countMcycle() public view returns(uint) {
        return mcycleownerAdds.length;
    }

// <---------- CREATION OF NEW MAP SO WE CAN QUERY BY LICENSE ---------->

//This seems to create two instances of each customer.  Replace with a better method.

mapping (string => Customer) mcyclelicenses;

function addLicense(string _custname, string _color, string _make, uint32 _year, string _license) onlyMember public {
    Customer storage mcyclelicense = mcyclelicenses[_license];
        mcyclelicense.custname = _custname;
        mcyclelicense.color = _color;
        mcyclelicense.make = _make;
        mcyclelicense.year = _year;

}

 function getMcycleByLic(string _license) public view returns(string, string, string, uint32) {
    return (mcyclelicenses[_license].custname, mcyclelicenses[_license].color, mcyclelicenses[_license].make, mcyclelicenses[_license].year);
}


texts:
I reviewed the other questions that had a similar error and they didn't help with my problem.

On my main net contract, with my MetaMask on main net, I am getting this error when processing transactions. I was trying to send funds to my escrow contract and the dapp only uses DAI. It is saying there is no DAI contract on main net??

Error:

Uncaught in promise error: DAI has not been deployed to detected network, network artifact mismatch

Here is my migration deploy contract js file. I used Truffle:

const Escrow = artifacts.require("./Escrow.sol");
const DAI = artifacts.require("./DAI.sol");

const DAI_COIN_ADDRESS = "0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359";

const ARBITRATOR = "0x000000000000etc...";

 module.exports = (deployer, network, accounts) => {
   console.log(accounts[0]);
   deployer.deploy(Escrow, DAI_COIN_ADDRESS, ARBITRATOR, {from: accounts[0]});
 };


texts: Return Token Contract address on truffle deploy

texts:
I am trying to figure out how to return the address of a contract when I deploy it with truffle's deployer.deploy.  So the goal is that when I deploy a contract that is a custom token, I want to return that address once it's deployed and pass that address to my CrowdSale contract constructor.  I am getting undefined for the instance of the deployed contract when doing this like so:

1_initial_migration.js

module.exports = function(deployer) {
  deployer.deploy(Migrations);
  deployer.deploy(CrowdTestToken).then((instance) => {
    console.log(instance);
    deployer.deploy(CrowdSale, instance.address);
  });
};

In the above example, instance is undefined.  Does anybody know how I can get the address of the CrowdTestToken contract in the deployment script?


texts:
Is there a library for Ethereum types, for tests written in TypeScript?
For example, an address type would be better to use instead of a generic string for Ethereum accounts.


texts:
Is there any special code you need so your token can be traded on exchanges example Binance?    Right now its a pretty basic contact like Fixed Supply token.

Or is it as long as the exchange(creates) has a etheruem wallet for your token, you can send your token to that exchange wallet?


texts: geth mining not working without --allow-insecure-unlock (geth 1.9.16-stable-ea3b00ad)

texts:
I am running a private ethereum blockchain with POA
geth --port 3000 --networkid 42 --datadir=./blkchain --maxpeers=5  --rpc --rpcport 8543 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --rpcapi "eth,net,web3,personal,miner" --allow-insecure-unlock  2>>eth.log

Then send transactions using Web3js
    let tx = {from:accounts[targetAccount],to:accounts[targetAccount],value: 0,gas: 100000, data:web3.utils.toHex(targetAccount)};
    web3.eth.accounts.signTransaction(tx, keys[targetAccount]).then(signed => {
       var tran = web3.eth.sendSignedTransaction(signed.rawTransaction);

       tran.on('transactionHash', hash => {
         console.log('write blockchain ', hash);
       });

       tran.on('error', console.error);
   });

Then miner.start() from geth console
Everything works fine.
But when I start geth again without --allow-insecure-unlock there are pending transactions:
(eth.pendingTransactions.length > 0) and sendTransaction always return:  Error: Returned error: already known.
I don't want to use this param: --allow-insecure-unlock.
Any hints for this? Many thanks!!
(If i start geth again with --allow-insecure-unlock, it seems to work again)


texts: Is possibly to create a Smart Contract that expire if the user doesnt move from own wallet in 30 days?

texts:
Well, I want to create my own contract and I will give like 10 coins to every user every month, but if the user doesn't transfer it from his own wallet, I want to "delete" this coins, to encourage transactions between the Community.

I was thinking in program this on a wallet.
But this is really the best way to do that?

Thanks

OBS: it's not a homework. I just wanted a direction, and I believe you guys have a lot more experience than I do.


texts: Two AWS nodes on separate machines are trying to peer.  They are listening and discovering at port 30303, when I open these ports for inbound connection they are still unable to peer; but, when I open 'All traffic' peering works.  So clearly my issue is with which ports/protocols are open/available; but, I cannot figure out which one(s) to open.


texts: Encode data fields, programmatically execute trade transaction


texts: How to catch contract exception in Web3 py?

texts:
I'm using infura.io with web3.py and I would like to catch exception thrown by smart contract. Currently, web3.py does not throw any exception even if the contract does, and hence it burns a lot of gas failing.
Since I'm using a public node, I have to sign the raw transactions before submitting
trans = contract.functions.addAdmin(address)
built = trans.buildTransaction({"gasPrice":...})
signed_tx = self.wallet.signTransaction(built)
tx_hash = self.web3.eth.sendRawTransaction(signed_txn.rawTransaction)

The problem is that addAdmin throws an exception, but web3 py will just send the transaction any way and does not propagate it. How can I detect the error before sending?


texts: What is valued at X dollars at an exchange? One... wei?

texts:
Assuming an exchange like Coinbase is selling "ETH" for $300USD:1ETH, and I give them $300 then how many of what exactly do I have?

Do I have one wei?
http://ethdocs.org/en/latest/ether.html


texts: Is there a way to create double-spending transactions and submit them to different nodes?

texts:
I'm trying to create two transactions with the same nonce and send those transactions to two different nodes. Such as:

const Web3 = require('web3');

const web3_1 = new Web3(rpcURL1); // node 1
const web3_2 = new Web3(rpcURL2); // node 2
const web3_3 = new Web3(rpcURL3); // node 3

// Let's call tx1
web3_2.eth.sendTransaction(
    {
        from: account0, to: account1, value: web3_1.utils.toWei("1", "ether"), nonce: 3
    }
);

// Let's call tx2
web3_3.eth.sendTransaction(
    {
        from: account0, to: account1, value: web3_1.utils.toWei("1", "ether"), nonce: 3
    }
);

I'm testing this on a private network with 3 nodes. All the nodes have each other as peers.

The error I'm getting when I run the code above:  Error: Returned error: known transaction: [txHash]

According to web3.js documentation, sendTransaction method returns a callback. Since I'm not waiting for this callback to be resolved, I assume transactions would be fired simultaneously or at very close times.

My guess is that since I'm using a private network and there are only three nodes, transaction propagation between the nodes is pretty fast (my assumption might be wrong). That's why, even though the transactions are submitted at very close times, tx1 is propagated to node3 before tx2 reaches node3. I believe that would be the only way for node3 to know about tx1.

If you think that's the case, is there any way in Ethereum to control the transaction propagation process or slow down it?

If you think that's not the case, what would be your suggestion for me to create these double-spending transactions on different nodes?


texts:
I am currently developing a smart contract which I will be needing to retrieve a random holder address and send them tokens. I will using oracle to get randomness, but my question is how store all the addresses so they are available for selection. Storing them all in the smart contract seems like storage abuse and I was thinking of creating a website that when retrieve the contract logs to get the addresses, then invoke a method in the contract to send them tokens. Does this solution seem feasible / suitable? Would the website need to be a dapp that would be linked to my meta mask account to pay the fees for the send transaction? I am very new to smart contracts / blockchain.
Thanks for any advice.


texts: How can we get the older state of a contract?

texts:
What I have

I have my private ehtereum chain running on an AWS EC2 instance.
I am able to deploy contracts on my private chain.
I am able to call functions of smart contract.

I am using truffle and react.

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

function NDA(bytes32 _party1name) {
     party1name = _party1name;
}

function SetParty2(bytes32 _party2name) {
     party2name = _party2name;
}

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

The above contract saves the 2 parties involved in a contract.
I am planning not to make a new contract everytime for 2 new parties but use the same contract as template and serve them from transactions which they do when they go in contract with each other.

To do so I should be able to go through the list of transactions of state update under that contract address for the specified user.

How can I travel back to an older state of a contract and fetch it?


texts:
I have an Ethereum folder which weights 2.5GB in this path:

C:\Users\xxx\AppData\Roaming

which has two folders in it:

  geth

  keystore

Do i need 'em ? It's not going to broke my instalation of ethereum on my comp ?


texts: Oraclize Sample contracts failing in JavaScript VM: VM Exception: out of gas / invalid opcode

texts:
I'm simply trying to run one of the sample contracts here at dapps.oraclize.it/browser-solidity/ e.g. DieselPrice.sol.

When I create the contract without passing a value I get VM Exception: out of gas and when I do pass a value I get VM Exception: invalid opcode.

I'm wondering what's happening here.. what am I doing wrong?


texts: What are the best Practices for writing truffle Tests for a Smart Contract ?

texts: I am currently having a project where a banking system is to be made, what is the approach to get into it. Its suggested to write the tests first and then proceed with the smart contract. What are the approaches to write a test with the "functions' " functionality in mind?


texts: Can abi.encodeWithSignature be optimized by pre-compute?

texts:
I have a proxy implementation with method exchange and delegator with method exchange2 with the following code:
function exchange2(int128 i, int128 j, uint256 dx, uint256 min_dy) public {
        (bool success, bytes memory result) = delegationTarget.delegatecall(
            abi.encodeWithSignature("exchange(int128,int128,uint256,uint256)", i, j, dx, min_dy)
        );
        if (!success) {
            if (result.length > 0) {
                revert(string(result));
            } else {
                revert();
            }
        }
        // pay cashback

this simple code above has about 2k gas overhead vs following openzeppelin proxy code:
    function _delegate(address implementation) internal {
        //        // solhint-disable-next-line no-inline-assembly
        assembly {
        // Copy msg.data. We take full control of memory in this inline assembly
        // block because it will not return to Solidity code. We overwrite the
        // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())

        // Call the implementation.
        // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)

        // Copy the returned data.
            returndatacopy(0, 0, returndatasize())

            switch result
            // delegatecall returns 0 on error.
            case 0 { revert(0, returndatasize()) }
            default { return(0, returndatasize()) }
        }
    }
    fallback () external {
        _delegate(delegationTarget);
    }

The problem with oz code, I don't know how can I delegate call to exchange of implementation from  exchange2 method of proxy.
Is there a way I can optimize abi.encodeWithSignature call if I know that signature of exchange(int128,int128,uint256,uint256) - 0x3df02124? It sounds wastfull to pass same string as an argument every time the function called.


texts: Save hash data with KECCAK-256 then reverse the process in PHP

texts:
I am saving data hashed with keccak-256 in Solidity and I am trying read that data with PHP, but cant seem to find any good solutions.

I can get PHP to read off the data but I cant arrive at the same resulting hash to compare the results from what PHP gives to what Solidity gives in order to confirm what the data is.

Any idea how I can make this work?


texts: How to decode input data with ABI using java?

texts:
There is a tool on npm ethereum-input-data-decoder. And yes, i can read input data as hex

byte[] bytes = Hex.decodeHex(transactionReceipt.getInput().substring(2).toCharArray());
System.out.println(new String(bytes, "UTF-8"));

But i need structured output. Like json for example. I want to do it using java. Not npm


texts: Who earns ETH from providing ressources allowing dApps to run?

texts:
I am trying to better understand how the ethereum network works but I didn't find a clear answer to that question yet.

I understand that ETH can be "used to pay for the computations that you ask the network to perform". I guess those computations performed by the network are another name for decentralized apps running.
Also, I read that running "a full node [...] won't get any ether reward.".

If I am correct, the two points above imply that resources allowing dApps to run are not provided by full nodes. They are not provided by miners either (miners just submit hashes in order to validate transactions AFAIK). So concretely where do dApps run, and who gets ETH for that? Can I do it?


texts: Creating a private Ethereum network on AWS using geth: Does it make sense to stop the instances to avoid costs?

texts:
I want to build a private Ethereum network on AWS using geth. To avoid costs, I want I'm thinking of stopping the instances where I won't be developing smart contracts or using my web app. Does stopping the VM's (nodes) and starting them up again when needed make sense?
A little bit more information, this is my first time attempting to build a private ethereum network. I'm planning on creating the network with 4 nodes, each node is a t2.micro Ubuntu VM.


texts: How are price changes based on time implemented in crowdsale smart contracts?

texts:
How can I implement a price structure into a crowdsale smart contract so that a price per token would be increased after a certain time?

I want to use best practices for this but cannot find information on this.

Would it be safe to use this kind of implementation?

  if(now >= phase1Start){
      rate = 200;
  }
  else if(now >= phase2Start){
      rate = 100;
  }

I would use the unix timestamp for the phase1Start and phase2Start variables, is this how it is done in crowdsales usually?


texts: Creating contract in ethereum-wallet using JSON-RPC on testnet giving "authentication needed: password or unlock"

texts:
I'm new to ethereum and blockchain technology. I'm trying to create my own crypto currency and using below JSON-RPC for creating new contract in our ethereum wallet on test network.

curl http://**.**.**.***:8545 -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from": "0xcfd3db0f1a6cb6cbbaf2b46f773444c3f13e1fe3", "data": "0x606060405260728060106000396000f360606040526000357c0100000000000000000000000000000000000000000000000000000000900480636ffa1caa146037576035565b005b604b60048080359060200190919050506061565b6040518082815260200191505060405180910390f35b6000816002029050606d565b91905056"}],"id":1}'

after using this command I'm recieving following error

{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"authentication needed: password or unlock"}}

I am confused what I am missing here, any help would be highly appreciated.


texts: Is it possible to schedule a transaction to execute after a certain amount of time in ethereum? For example, I have a dapp where after two weeks I want to call a getRefund function on the smart contract (I already know the end date), but I don't want the user to manually execute the request. If yes how can i do it in web3.js?


texts:
How does chainlink result aggregation work?
Are all oracle nodes that user-specified reports the results to the smart contract that chainlink is submitted on Ethereum? Is taking a median off aggregated results happens on the chainlink smart contract?
or
"watchdog" is the one that is selected randomly aggregates the result on off-chain and reports them to on-chain?


texts: Try running MyCrypto with my local parity nodes?

texts:
i want connect my local parity nodes with Mycrypto i flowed this tutorial to built my two nodes https://wiki.parity.io/Demo-PoA-tutorial.html
than i try to flow this tutorial to connect it to Mycrypto https://support.mycrypto.com/networks/run-your-own-node-with-mycrypto.html

im still straggling with connect my nodes to Mycrypto i need some help plz
both my nodes work fine in terminals and they connected together and have users addresses and i can send eth from one to another fine by terminals.

so what is chain ID i tryed to add Enode URL and its not work i dont know how to connect that

thank you


texts: How can I connect to public chain using web3?

texts:
I have used web3 to interact with my private chain by using :

web3.setProvider(new web3.providers.HttpProvider("http://localhost:8012"));

But How can I connect to Public Network using web3?

I am trying to make a web interface for interaction with my contract( which deployes, where you can use all the functions provided by my contract using my web interface. I have done this on private network and everything worked seamlessly.
But now I have doubt that whether I can replicate same on public network.
For example let my contract address be x and contract ABI be y and I have a function named transfer to transfer coins. I have done this on private network:

web3.setProvider(new web3.providers.HttpProvider("http://localhost:8012"));
var contract1=web3.eth.contract(y).at(x);
contract1.transfer(to, amount, {from: frm});

Also can I unlock my account using RPC ? I mean if my users want to create an address, If I can ask for password from them and use web3.personal.newAccount(password);.

To summarise:

Can I access my contract on Public network using web3? If yes, How?
Is personal exposed over RPC? I mean if I have to generate addresses or unlock account using web3, how can I do that?
There are api that provide Ethereum addresses, how do they work?


texts: Correct Syntax using Web3 for Contracts with multiple parameter methods

texts:
Working with a contract that has multiple parameters just wondering what the correct syntax would be for.

// creation of contract object
var MyContract = web3.eth.contract(abi);

// initiate contract for an address
var myContractInstance = MyContract.at('0x78e97bcc5b5dd9ed228fed7a4887c0d7287344a9');

var result = myContractInstance.myConstantMethod('myParam');
console.log(result) // '0x25434534534'

myContractInstance.myStateChangingMethod('someParam1', 23, {value: 200, gas: 2000}, function(err, result){ ... });

//This is where I'm not sure???????
myContractInstance.myStateChangingMethodMultiParm('someParam1', 23, 'someParam2', 23, {value: 200, gas: 2000}, function(err, result){ ... });
// Or
myContractInstance.myStateChangingMethodMultiParm({'someParam1':23, 'someParam2': 23}, {value: 200, gas: 2000}, function(err, result){ ... });


texts: How to decrypt an ECIES encrypted message using a geth account and JSON-RPC protocol?

texts:
A geth node is managing an Ethereum account, having the control over its private key at keystore folder. I guess to keep it safe, best practices are letting geth by its own perform all operations that require access to the private key. Well, the case is I need to decrypt a message that was encrypted using the public key of the geth account, in order to be only readable by this account. So, is there any geth function via JSON-RPC capable of decrypting a message using the private key of the account? Something like this:

ECIES.Decrypt(account, message);

The only other choice is left seems to be accessing directly to the keystore folder and decrypt the message using the private key there, but I don't feel comfortable doing so, it seems a quite insecure scheme, right?

Ref.:

How to encrypt a message with the public-key of an Ethereum address


texts: Truffle Test: How to send ether to a contract from a contract?

texts:
Would like to test the modifier below

modifier isNotAContract(){
    require (msg.sender == tx.origin, 'Contracts are not allowed to interact.');
    _;
}

How can I invoke a function using this modifier by a contract?

Javascript syntax prefered!


texts: TypeError: tokenInstance.balanceOf is not a function

texts:
It happen when use truffle test,

here my contract file:

pragma solidity ^0.5.0;

import "./DappToken.sol";

contract DappTokenSale {

    address payable admin;
    DappToken public tokenContract;
    uint256 public tokenPrice;
    uint256 public tokensSold;

    event Sell(address _buyer, uint256 _amount);

    constructor (DappToken _tokenContract, uint256 _tokenPrice) public {
        admin = msg.sender;
        tokenContract = _tokenContract;
        tokenPrice = _tokenPrice;
    }
    function multiply (uint x, uint y) internal pure returns (uint z) {
        require(y == 0 || (z = x * y) / y == x);
    }

    function buyTokens (uint256 _numberOfTokens) public payable {

        require (msg.value == multiply(_numberOfTokens, tokenPrice));
        require (tokenContract.balanceOf(address(this)) >= _numberOfTokens);
        require (tokenContract.transfer(msg.sender, _numberOfTokens));

        tokensSold += _numberOfTokens;
        emit Sell(msg.sender, _numberOfTokens);
    }
        function endSale () public {

            require (msg.sender == admin);
            require (tokenContract.transfer(admin, tokenContract.balanceOf(address(this))));
            selfdestruct(admin);
        }

    }

and here my DappTokenSale js file:

var DappToken = artifacts.require('./DappToken.sol');
var DappTokenSale = artifacts.require('./DappTokenSale.sol');

contract('DappTokenSale', function(accounts) {
    var tokenInstance;
    var tokenSaleInstance;
    var admin = accounts[0];
    var buyer = accounts[1];
    var tokenPrice = 1000000000000000;
    var tokensAvailable = 750000;
    var numberOfTokens;

    //Some code i turn off for simplicity

    it('end token sale', function() {
        return DappTokenSale.deployed().then(function(instance){
            tokenInstance = instance;
            return DappTokenSale.deployed();
        }).then(function(instance){
            tokenSaleInstance = instance;
            return tokenSaleInstance.endSale({from:buyer });
        }).then(assert.fail).catch(function(error){
            assert(error.message.indexOf('revert' >= 0, 'must be admin to end sale'));
            return tokenSaleInstance.endSale({from: admin});
        }).then(function(receipt){
            return tokenInstance.balanceOf(admin); //<-- I think prolem is here but don't know how to fix it.
        }).then(function(balance){
            assert.equal(balance.toNumber(), 999990, 'return all unsold dapp tokens to admin')
            return tokenSaleInstance.tokenPrice();
        }).then(function(price) {
            assert.equal(price.toNumber(), 0,'token price was reset')
        });
    });
    });

How I can fix this ? i don't know which mistake i made :


texts: How to Make Geth 1.9+ Full Node to Trace Ancient Blocks?

texts: I have full-synced a Geth 1.9.9 node but my requests including ancient blocks erroring. I know this is because of state-pruning but I wonder how to enable tracing for an ancient block so it returns the result instead of an error.


texts: Query a block explorer to return the balance of a specific type of token in an ethereum address?

texts: Is there a block explorer where one can query an address and it outputs the balance of a specific type of token? Is there an example of how this can be done?


texts: Error when executing sendRawTransaction on kovan testnet

texts:
I am trying out execute sendRawTransaction on kovan testnet.

I'm following the instructions described in https://kovan.etherscan.io/apis#proxy. I'm using a POST request to send the request.

This is the data I'm trying to send as hex parameter

0x3ce49e670000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000007506c7bfed179254265d443856ef9bda19221cd7000000000000000000000000000000000000000000000000349f4957d8d5a7300000000000000000000000004dffea52b0b4b48c71385ae25de41ce6ad0dd5a7

After api call execution I'm getting the following response

{
    "jsonrpc": "2.0",
    "error": {
        "code": -32602,
        "message": "Invalid RLP.",
        "data": "RlpIncorrectListLen"
    },
    "id": 1
}

What am I missing or doing wrong?

Thanks


texts:
The modifier used to check if a contract calls a function in Solidity used the assembly code extsize. I wonder why this is done. Using assembly seems very "hackish" to me (why does solidity not have a 'normal' function to check this?). The code in question is

modifier noContract(address _addr){
  uint32 size;
  assembly {
    size := extcodesize(_addr)
  }
  require (size == 0);
  _;
}

(edited from https://ethereum.stackexchange.com/a/15642/33191)

Why not use msg.sender == tx.orgin as check? Is there a loophole in this?

Is the reason for using extsize that this might use (slightly) less gas?


texts: How many Smart Contracts are deployed on Ethereum at the moment?

texts:
I have seen the same question being asked before, but it was kind of out of date.

Etherscan.io only shows me the last 500 verified Smart Contracts on Ethereum, but not the total number.

Is there an easy way to find the current number?

Thank you


texts:
It´s posible to save structs inside array and all this array´s inside the same array. I mean:

[ [{"struct"}, {"struct"}, {"struct"}], [ {"struct"}, {"struct"}], [{"struct"}, {"struct"}, {"struct"}, {"struct"}] ]

I can´t find something related to this in the web.

And is efficient to implement this storage system. If the array is so big can increment the transaction cost. Is profitable?


texts: Can a smart contract in Go language be deployed to azure ethereum consortium blockchain? If yes, how?

texts: I have a smart contract(created in GO language) working for IBM bluemix blockchain. This work was done by a separate team.I need to create a replica of the same using a Azure Ethereum blockchain. I am very new to the blockchain and smart contract technologies. Can I use the same smart contract(Go language) for the Azure Ethereum consortium blockchain? If yes, how will I compile and deploy it?


texts: so I was looking around for a decent up-to-date tutorial to start developing native dapps (C++ or GO doesn't really matter), but I can't seem to find a concise tutorial rather than this one. Can someone give me a link where I can start? Also I'd have to clarify that I'm looking to implement a local database for the dapp that is why I don't want to use the web3 library, which tbh looks way easier.


texts: Is it possible to burn the balances of a contract from another contract?

texts:
Imagine the scenario in which contract A has in its possession 1000 tokens (of the contract itself). is it possible to create a second contract and burn the tokens of contract A?

contract ContractA is DetailedERC20 {

    uint8 public constant decimals = 18;

    uint256 public constant INITIAL_SUPPLY = (500 * (10**6)) * (10 ** uint256(decimals));

    constructor(string _name, string _symbol)
    public
    DetailedERC20(_name, _symbol, decimals)
    {
        totalSupply_ = INITIAL_SUPPLY;
        balances[this] = INITIAL_SUPPLY;
        emit Transfer(address(0), this, INITIAL_SUPPLY);
    }
}

Contract B (PSEUDO)

contract ContractB {

    ERC20 public token;

    constructor(ERC20 _token) public {
        token = _token;
    }

    function burn() internal {
        token.balances[address(token)] = 0;
        token.totalSupply_ = 0;
    }
}

Sorry if looks strange, but i'm a noob in Solidity


texts: truffle console - return (array of addresses) issue

texts:
This problem happens only when I place contracts A and contract B in seperate file. When placed in same file, I get the array elements perfectly

Please find the contract below. I was able to successfully compile and migrate the same.

pragma solidity ^0.4.8;

import "./B.sol";

contract A {

   address[] public addElements;

   function A() payable {

   }

   function create() returns (address a) {
       B obj = new B();
       addElements.push(obj);
       return obj;
   }

   function getElements() returns (address[] ) {
       return addElements;
   }

}

//  <<<< This is in a different file        >>>>

pragma solidity ^0.4.8;

contract B {

   function B() {

   }

}

Now I am using truffle console and trying to invoke getElements() function to get back the arrays and would like to loop through them
However, I don't see any array elements.

Output attached.


texts: Return parameters is not getting translated to java using web3j cli

texts:
When using newest version of solidity compiler "pragma" solidity ^0.6.9
The program compilation is successful.
I'm just using this code

Contract Counter{
           unit  public Variable_name;
           function increment() public{
                 Variable_name ++;
                }
}

But when transcode using web3j Variable_name is  not returned and nor get the values using java using java transcoded contract.The problem is not present in previous versions of solidity compilers.


texts: How to make a delegatecall to external ERC20 token's approve function?

texts:
What I would like to do is something like this:
function testCall(uint amount) public virtual returns (bool) {
address tta = address(0xE7B6....);

(bool success, bytes memory result) = tta.delegatecall(abi.encodeWithSignature("approve(address, uint256)", address(this), amount));
return success;
}

The token looks like this (has the approve function)
However, whenever the function is executed, it reverts with an error.
What am I doing wrong?
What I need to accomplish is to let the user approve the contract to make a transferFrom by executing the contract's testCall() function first.


texts:
In which basis transactions are stored in a new block? first come first serve or higher transaction fee???
the miners gather up as many transactions as can fit into a block, and go through a mathematical process to verify the block and add it to the chain of past blocks. Miners are rewarded in freshly minted bitcoin for contributing their computing resources to the network.


texts: altcoin investment management in ethereum ICO

texts:
I have observed that these days ethereum ICOs are also allowing payment using some cryptocurrencies (bitcoin, litecoin etc.) except ether. They ask to signup from user, create a unique altcoin address for that particular user and asks to transfer coins to that address. Once some amount of coins is transferred to the address, calculated tokens are visible to that user's dashboard. Now my questions are :
 How those tokens are extracted from the token contract ?  Had any ether value corresponding to the transferred coin stored in the crowdsale contract ?  How a user will be able to transfer these tokens ? Which part is automated in this process and which one is manual ? Basically i want to know what is happening behind the scenes. Let me know if you want any extra detail. Any kind of addition of knowledge regarding the question is most welcome.


texts: Truffle test, order of execution and changing the state

texts:
I have a smart contract with a payable function. My test want to check if that function call will actually increase contract balance, and they apparently works.

it("can present new user", async () => {
    let instance = await MyContract.deployed();
    //presenter is the contract creator
    let presenter = accounts[0];
    let from = accounts[1]; //new user joining
    await instance.join(presenter,{value:web3.toWei(10,"finney"), from:from});
    let balance = await web3.eth.getBalance(instance.address);
    assert.equal(balance.valueOf(), web3.toWei(10,"finney"));

 })

 it("can't present twice", async () => {
  let instance = await MyContract.deployed();
  //presenter is the contract creator
  let presenter = accounts[0];
  let from = accounts[1]; //new user joining
  await instance.join(presenter,{value:web3.toWei(10,"finney"), from:from});
  let balance = await web3.eth.getBalance(instance.address);
  assert.equal(balance.valueOf(), web3.toWei(10,"finney"));

})

Then I did another testing function in order to check if calling twice with same parameter disallow the transaction, and it works, but this assumes that:

test inside the same test contract are executed in a certain order
state of all account are
committed in the test chain after function call

is this safe to assume?


texts: How do I build Dapp Application that Stores Images

texts:
I am building a Dapp application.  One of my use-cases is storing a large number of images.  How can I accomplish this on Ethereum?

My architecture /correct me if I am wrong includes
 DaPP(smartcontract) ---->Oraclize --->API ---->DB(mongo etc..)

Is there an easier way of doing this?


texts: Format of LevelDB files in nodes directory? Trouble pulling contents with python leveldb API

texts:
I am interested in exploring the data in ~/.ethereum/nodes, which I believe contains previous connection attempts and information about the nodes. (Is that correct?) But I am stuck trying to pull the data from that database.

Here is my attempt so far:

import leveldb

db = leveldb.LevelDB("./nodes")
# I don't know the format so I will iterate a few keys
keys = list()
for k in db.RangeIter():
    if len(keys) > 10:
        break
    keys.append(k)

print(keys[0][0])

Which gives me a byte array that I don't know what to do with:

>>> bytearray(b'n:\x00\x00\x07\xf2\x91\xff\xcd\xba%\x8f%\xf8b\xfe\x1b3\xda\x10\xfa,\xb7>\x93\x82_X\r5\xdfG\xae\x8b\xd6-\x9d6\rB\x84$\xb8+\x07\x18<\x8d\xed\xca\x93\xa4\x0bt\x84\xa7\x14\xaf\xc8B\x1a\xb3\xb7(K\x00:discover:lastping')

Sorry if this is more of a python than an Ethereum question, but I suspect knowing the structure of the data would help and I can't seem to find it anywhere.

UPDATE:
I should clarify what I am working with:

keys[0] is an entry in the nodes database and is a tuple:

(
 bytearray(b'n:\x00\x00\x07\xf2\x91\xff\xcd\xba%\x8f%\xf8b\xfe\x1b3\xda\x10\xfa,\xb7>\x93\x82_X\r5\xdfG\xae\x8b\xd6-\x9d6\rB\x84$\xb8+\x07\x18<\x8d\xed\xca\x93\xa4\x0bt\x84\xa7\x14\xaf\xc8B\x1a\xb3\xb7(K\x00:discover:lastping'),
 bytearray(b'\x90\xa7\xae\xef\n')
)

With the first item being the key. Running rlp.decode on either item returns an error:

import rlp

rlp.decode(bytes(keys[0][0]))
>>> DecodingError: RLP string ends with 83 superfluous bytes

rlp.decode(bytes(keys[0][1]))
>>> DecodingError: RLP string ends with -12 superfluous bytes

I'm very confused because it looks like it's being RLP encoded by geth so I don't understand why it would fail to decode.


texts: Error: gas required exceeds allowance or always failing transaction upon function execution

texts:
Problem
The transaction fails because the transaction ran out of gas instead of it failing because the require condition was not met. It works fine before the solidity update to version 0.4.24. It works in all environment. It can even return the reason I provided with the error in the require parameter. Why is it saying that the gas is not enough? I've tried to assign a higher gas limit, higher than 3000000. I am using remix.ide

Note
Everything works fine if I don't make the require onlyOwner modifier to result to an error.

Contract Code

pragma solidity ^0.4.24;

 contract Owned {
 address public owner;
 address public newOwner;

 event OwnershipTransferred(address indexed _from, address indexed _to);

 constructor() public {
     owner = msg.sender;
 }

 modifier onlyOwner {
     require(msg.sender == owner);
     _;
 }

 function transferOwnership(address _newOwner) public onlyOwner {
     newOwner = _newOwner;
 }

 function acceptOwnership() public {
     require(msg.sender == newOwner);
     emit OwnershipTransferred(owner, newOwner);
     owner = newOwner;
     newOwner = address(0);
 }
}

Using JavaScript VM Environment

-The image above is the result I expect to get when I use the Injected Web3 and Web3 Provider Environment as that is how it works before around the solidity version 0.4.23.

Using Injected Web3 and Web3 Provider Environment

--The window on the above image will pop-up upon execution of the transferOwnership() function. The function with the onlyOwner modifier which require the msg.sender to be equal to the contract owner.

--The image is the result when I choose to still proceed with the transaction even after the warning from the 2nd Image. It results to the same "Transaction mined but execution failed" status like when I ran it using the JavaScriptVM Environment but without the "VM error: revert." return.


texts: What is Parser Error? How to solve this problem?


texts: Hit a require or revert statement somewhere in its constructor?

texts:
I'm trying to fork a token contract and deploy it locally using ganache but I keep running into the following error:

I have tried to debug the error using truffle debug 'transaction' and find the following:

Now since there's no assert(), revert(), or require() statement I believe it's an out-of-gas exception error. However, one odd thing I've noticed is that after commenting out those two lines and trying to compile it still throws an error on those lines:

According to this post, comments do not affect the gas cost and I don't see how commented out code could be throwing one of the other errors.
Does anyone know what's going on here?


texts: What is the Correct Method of Calling a Function of a New Contract?

texts:
what is the correct way to call a method of a contract that has recently been created.

following the example on the officially documentation (https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#new-contract), i have successfully created and deployed a new contract instances with the following code:

import commentContract from '../build/contracts/Comment.json';

const comment = new web3.eth.Contract(Comment.abi, { from: coinbase });

comment.deploy({ data: commentContract.bytecode })
    .send({ from: coinbase, gas: 1500000 })
    .then(deployedContract => {
        // return deployedContract.methods.setText('some text here', {from: coinbase})
        //     .then(result => console.log(result))

        return deployedContract.methods.setText('some text here')
            .then(result => console.log(result))
    });

this code does not work because of an error that setText expects only 1 parameter, instead 2 supplied ( because of {from: coinbase}). so i removed the {from: coinbase} part from the code and now it gives an error that then is not defined.

so i cant figure out what the correct way would be to call methods on this newly created contract.


texts:
We are looking to allow our users to buy/sell USDT-ERC.
I am confused about how this process works. Initially thought they could just allow them to buy/sell directly using web3 and the USDT ERC20 contract. It seems you can't do this as there is no function to buy.
Now I am thinking we need to buy USDT-ERC into our own master ETH address and then use that mater address to allow our users to buy/sell. Would this be the correct way?
How can we buy USDT-ERC into our own master ETH address?


texts: Solidity default contract attribute/method scopes

texts: Reading this thread, it's mentioned what the keywords public, private, internal and external represent, but what is the default specifier for methods and/or attribute contracts in solidty?


texts: build geth from Ethreum source code in WIndows

texts:
I want to build geth form source code in windows and do as it (https://geth.ethereum.org/docs/install-and-build/installing-geth#building-without-a-go-workflow)says, but after I execute"go install -v ./cmd/..." I get as folllows:
 D:\GoPath\src\github.com\ethreum\go-ethereum>go install -v ./cmd/...
 # gopkg.in/olebedev/go-duktape.v3
 duk_minimal_printf.c: In function 'duk__parse_pointer':
 duk_minimal_printf.c:126:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]   126 |
        *out = (void *) val;
              |         ^
duk_minimal_printf.c: In function 'duk_minimal_vsnprintf':
duk_minimal_printf.c:236:76: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]   236 |     off = duk__format_long(str, size, off, sizeof(void *) * 2, '0', 16, 0, (unsigned long) v);

what is wrong?so what can i do to solve it ?I expect someone can help me,Thanks very much!!!!!!


texts: block syncing current is smaller than starting why?

texts: I'm sync the chain after a power cycle, so current is behind highest for sure, but I also saw that current is falling behind starting block number, how is this possible? starting is the highest on disk when geth starts to run, right? so i already have up to starting on my computer.


texts: invalid state after miner rejects transaction

texts:
I refer to the transaction flow in the following link:

https://web3j.readthedocs.io/en/latest/_images/web3j_transaction.png

What happens if the transaction is propagated to other ethereum client (not miners yet) and these clients are already processing the transaction but when the miner process it, this transaction is invalid and not included in the block.

What happens to the other ethereum clients which have first processed the transaction before the miner got hold of it? What happen to their state?