texts: Create new address in Ethereum using Nethereum

texts:
I try to create new account.

var web3 = new Nethereum.Geth.Web3Geth();

var ecKey = Nethereum.Signer.EthECKey.GenerateKey();
var privateKey = ecKey.GetPrivateKeyAsBytes().ToHex();
var account = new Account(privateKey);

in account i recived

{"privateKey":"0x062f0c51f1949b6cf14329df0fe59c739f98fdfdbef8a70e885c1d028f999a12","address":"0xDd8414810DC6111BEed80383D20AA2A0313BCd51","transactionManager":{"defaultGasPrice":20000000000,"defaultGas":21000,"client":null,"transactionReceiptService":{}},"nonceService":null}

but in testchain  this address not added

web3.eth.accounts
["0x12890d2cce102216644c59dae5baed380d84830c", "0x13f022d72158410433cbd66f5dd8bf6d2d129924", "0x3a2e25cfb83d633c184f6e4de1066552c5bf4517", "0xaf7c2c210d31245cf332fc1d820bdfd77d1e3555", "0xfd1a70a36f6369d369ce58fe3aa012eb2d8593ab", "0xb6d706ddeece5f9c118073ddceaca5578eea474d", "0xbf5c0f806d6cd0778b8263e803315422a7afd684", "0x711cdc94ae25c5b2f2005b10c13b67bccb82fea7", "0x6d5d2f40cc9f353b83f9a2f53615d3ecbf5447f5", "0x04ce8794628f6640636032cd8e44e62e80816871", "0x7429958b6ba7fc693ef34c466b00f4d34633e6a0", "0xe24d16f8aa08f384cfc480e97a000c53d04c36e5", "0x3448664731d7d1e29078d0f72f6f5db826fec8d7", "0x38bef2ee44b565274789e7fa3b212ddca8b175cc", "0x48a44c89a45fb9a35ebe34dfada675f1473f39e6", "0x009c366f337bbc672d383c50ffa60654c5ca54a3", "0xf2be7e6940ce3827d07fa12c3df8a9167d92da30", "0x3193aca2ea0dc9e841ac237283fa6ba22fe473dd"]

What i must do to create new account?


texts: How do I install Go-ethereum and solidity on Debian10

texts: I am using debain on wsl and I want to install ethereum and solidity for blockchain development but I am not able to find an exact way to do it.


texts:
I need get info about crowdsale.

By example, here, there is information about the number of tokens sold, Hardcap and so on. This information, as indicated on the site, is updated every 60 seconds.

I need to get the same information to display on the website, but I do not understand where to get it.

Example of information:

  PRESALE (SOLD OUT) - 70,000,000

  PRG TOKENS SOLD (CROWDSALE) - 3,550,921

  PRG Hardcap - 30,000,000 PRG

I understand that I need to use https://etherscan.io/apis, but having studied the majority of methods, it seems none of them gives me the necessary information.


texts:
I was looking at the standardized contracts page and was confused by the description for setSubRegistrar and subRegistrar.

Here's the description for setSubRegistrar: Records the name as referring to a sub-registrar at the given address.

I understand what a registrar is but am confused by the idea of a sub-registrar and was hoping someone could give a better explanation.


texts: Creating a contract with constructor in ethereumj

texts:
contract Calculator{
    int result;
    function Calculator(int initialResult){
       result=initialResult;
    }
}

If above is the contract source code I have created then how to call Calculator function using ethereumj API. I have already used

contract.callFunction("Calculator", 10)

But this did not work. Also called

contract.callConstFunction("Calculator", 10)

But this too didn't not work.

And when saw the ABI it had the function type ="constructor" but couldn't find any method that represents calling constructor.

Please suggest if there is any way to call constructor functions?


texts: how to get the last incoming transaction before date

texts:
I need to get the incoming transaction before the date currently i use

https://web3api.io/api/v1/addresses/0xaD4b04Df17f2d35F81771Fa124dBD94E33587F4c/transactions?to=0xaD4b04Df17f2d35F81771Fa124dBD94E33587F4c&size=1

The above API returns recent incoming transaction .I want incoming transaction of account before 3 Nov. In that case how do i get that incoming transaction.


texts:
Today I wanted to buy me a cryptokittie. Because I wanted to buy the cat, I downloaded Metamask and put some Ether in it.

My transaction to buy some kittes were not realized at the end, but still I had to pay a fee.

(I put the information out of ethereumscan at the end of this mail)

My question now is: is it normal that I have to pay a fee (gas) even if the transaction never was done? For what am I paying? Who gets the money I paid?

What does the error code "out of gas" means?

0x92c0e9ee27f9a3541480fd21290727d143bd4485bc75311d32db9947b2cb68a6

4886613

1 hr 14 mins ago

0x532d9907702385bfc78b26950a530a744939e572

OUT

CryptoKittiesSalesAuction

0.005 Ether

0.0015


texts:
I want to accept payments on my website. The idea is that for every user I create his own private key from a temporary address and when he sends some tokens to this address - I transfer money from this account to my one with the private key for which only I have access. But I don't have an idea of how to pay for transactions from a temporary account to my one without gas. I see only two ways that are not comfortable enough for me:

Force users to send an additional 0.01 ETH to the temporary wallet after every transaction
Send 0.01 ETH from my own wallet to the temporary wallet to allow the temporary wallet to send back tokens to me

Are there better ways?


texts: How to find out whether an address is already in the mapping

texts:
If I have a mapping like this

struct data {
   string name;
   string nickname;
}

mapping(address => data) public user;

How can I find out whether an address is already in the mapping or not?

if (user[_address])

does obviously not work.


texts: Unstructured storage proxies. Variables not being overwritten?

texts:
When using delegate call I was under the impression that storage slots declared in the proxy will be overwritten by the implementation.

Unstructured storage implementations declare bytes32 variables that indicate the storage position within the proxy to find owners, implementations etc.

Why aren't these bytes32 variables being overwritten when a transaction is delegated to the implementing contract? The examples of implementing contracts don't seem to take into account these variables already declared.

contract OwnedUpgradeabilityProxy is Proxy {
 bytes32 private constant ownerPosition = keccak256("org.zeppelinos.proxy.owner");
 bytes32 private constant implementationPosition = keccak256("org.zeppelinos.proxy.implementation");

 function upgradeTo(address newImplementation) public onlyProxyOwner {
   address currentImplementation = implementation();
   setImplementation(newImplementation);
 }

 function implementation() public view returns (address impl) {
   bytes32 position = implementationPosition;
   assembly { impl := sload(position) }
 }


texts: geth throwing header invalid error all the time

texts:
lately my ethereum node is repeatedly throwing this error:

E0811 16:44:00.646126 core/blockchain.go:1128]     uncle[0](30508438) header invalid: nonce for #2004585 [30508438247525b01fa303eb0d417d7a18c69862c18ff7931127152b1db756f1…] is invalid (got 2961809790923137721)
E0811 16:44:00.646097 core/blockchain.go:1127] Bad block #2004591 (0x71249cfe1478a692ad61506201574a997aa9cdccb6a278bd19ea067466e4f88a)

I use this command to launch geth:

geth --rpc --oppose-dao-fork

This is my version:

$ geth version
Geth
Version: 1.4.10-stable-5f55d95a
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.6.2
OS: linux
GOPATH=
GOROOT=/opt/google/go

What does it mean? Why the error? Any fix? Any help? Thanks in advance!


texts: Calculate deposit amount when adding to a liquidity pool in Uniswap v3

texts:
Suppose:

The price of an A/B token pair is price_now
The user wants to provide liquidity in the range price_low to price_high such that price_low < price_now < price_high
The user supplies X amount of token A

What amount of token B needs to be deposited? For example 2907.47 USDC would be needed if I want to supply 1 ETH in the screenshot. I need a math formula.


texts: Deploying contracts in Ropsten with Truffle

texts:
I have another n00b question... sorry about that :(

I'm trying to deploy a smart contract to Ropsten. I have synched the Ropsten network with geth --testnet --fast --rpc --rpcapi eth,net,web3,personal, and it looks perfectly up to date.

Then I try to deploy that smart contract (which I've already deployed to my private testrpc network and it works poerfectly) to Ropsten. To do so I'm executing truffle migrate --network ropsten and I'm getting this pesky error:

Could not connect to your Ethereum client. Please check that your Ethereum client:
    - is running
    - is accepting RPC connections (i.e., "--rpc" option is used in geth)
    - is accessible over the network
    - is properly configured in your Truffle configuration file (truffle.js)

The geth instance is in fact up and running, since I can connect to it with geth attach http://127.0.0.1:8545 and it works fine. It is accepting connections, since I used the --rpc option. It is accessible over the network because I've already accessed it... and I think than my Truffle configuration file is ok, here's how it looks:

require('babel-register')

module.exports = {
  networks: {
    development: {
      host: 'localhost',
      port: 8545,
      network_id: '*' // Match any network id
    },
    ropsten: {
      host: "localhost",
      port: 8545,
      network_id: "3",
    }
  }
}

Can anyone please tell me why am I getting this error and what can I do to fix it?

Thank you so much in advance!!! :)


texts: Why are the last 20 bytes of the public key used as the address?

texts:
According to this post regarding how to derive the Ethereum address from a public key:

  Take the last 40 characters / 20 bytes of this public key
  (Keccak-256). Or, in other words, drop the first 24 characters / 12
  bytes. These 40 characters / 20 bytes are the address. When prefixed
  with 0x it becomes 42 characters long.

My question is why the last 20 bytes (as opposed to something other than 20), is it an arbitrary decision or is there an underlying mathematical purpose to it?


texts: Transfering ETH from Coinbase to Parity, but it does not show up on Parity user

texts:
I tried to transfer 2 eth from a coinbase account to a Parity user (Not wallet). It does not show up on Parity after 5 hours of waiting.
In Coinbase, it says that the transaction is complete, and on etherscan it says that it is complete, too. The only problem is the Parity user.


texts: DeclarationError: Undeclared identifier. But already declared

texts: DeclarationError: Undeclared identifier.on line 8,12,14.


texts: Can a new deterministic address be generated with only an Ethereum public key?

texts:
BIP-32 defines a way to generate a new address with only knowledge of only the public key for that wallet

Deterministic wallets ... permit schemes where one can calculate the public keys without revealing the private keys. This permits for example a webshop business to let its webserver generate fresh addresses (public key hashes) for each order or for each customer, without giving the webserver access to the corresponding private keys (which are required for spending the received funds).

So if BIP-32 Allows for a derivation from Public parent key → public child key  , Such that if funds were sent to the derived key then they would be accessible by the public parent key. My question is asking is this possible on Ethereum?


texts:
I have currently set up a truffle project with react, redux and react-router.
I just finished writing my first implementation of the smart contract, and now want redux to connect with the smart contract. I have tried reading up on several pages, including this:
https://truffleframework.com/docs/drizzle/getting-started/using-an-existing-redux-store

However, I cant seem to figure this out. I have now set up my store as follows:

import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from './reducers/rootReducer';
import ItemList from "./utils/getItems";

//drizzle
import { generateContractsInitialState } from "drizzle";
import ItemOwnershipContract from "./contracts/ItemOwnership.json";

export default function configureStore() {
const options = {
    contracts: [
      ItemOwnershipContract
    ]
  }
const initialState = {
    contracts: generateContractsInitialState(options),
    account: "1",
    items: new ItemList().itemList,
    equipSelector: "0",
    raritySelector: "0",
    chosenItems: [-1, -1, -1]

}

const enhancers = applyMiddleware(thunk) &&
    (window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());
return createStore(
    rootReducer,
    initialState,
     enhancers
);
}

(appologies for the indentation).

How do I now do the following:

Get account address from current user?
Do I still need to use web3 to see if I have connection with the given blockchain?
Will this automatically update the store whenever the content of the smart contract gets updated? Or do I need to force update it?
In that article, they simply call generateContractsInitialState() on "./drizzleOptions", but never shows us the file. What will it contain? A way struct with the contracts array field, and passed in a json file?
do drizzle store my current account address, or do I need to use web3 to fetch that?

I am aware there is a lot of questions here, but I am not very familiar with any of these tools, so I dont quite understand it. Thank you in advance!


texts: Manually execute transactions using testrpc and truffle

texts:
I started doing a bit of work in the geth console:

geth --dev console

but have moved to developing using truffle.

To debug in the geth console, I'm used to executing the following:

eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(1, "ether")});

then manually calling miner.start().

Is there a way to do this using testrprc?


texts:
I am writing a smart contract that necessarily must have structs stored within an array. For example:

struct number {
uint number;
bool isCurrent;
}

number[] nums;

To add onto the array, I use the following command:

nums.push(number{number: 1, isCurrent: true});

My first question: is this a valid way of adding a new struct to the end of the array?

Second, to make my code more readable, I often do the following when I am trying to refer to a certain struct within the array (assume that nums[0] is what I pushed onto the array above):

var aNumberStruct = nums[0];
aNumberStruct.number = 2;

Does this change the value of "number" within the struct at nums[0]? Or does it simply make a copy of the struct, making it so I am not actually changing any data within the struct (at nums[0]) at all?

Thanks for any help. I really appreciate it.


texts: Could I implement a kill switch in my solidity program?

texts:
I was wondering if there was a way to put a killswitch into my solidity code?
I am using v0.4.21+commit.dfe3193c

Thanks a bunch!


texts:
According to https://ethervm.io, when CALL instruction is executed, the stack layout like this:

[address, value, argOffset, argLen, retOffset, retLen]

So CALL would pop 6 words from stack bottom to retrieve necessary information.

But when I looked at the opcode of this Solidity code:

contract Test {
    function withdraw() public {
        uint x = 123;
        msg.sender.call.value(x)();
    }
}

I can see the related opcode is like below:

33  caller
90  swap1
82  dup3
90  swap1
60 00  push1    00
81  dup2
81  dup2
81  dup2
85  dup6
87  dup8
5a  gas
f1  call

We can see that before CALL, GAS push the remaining gas into stack bottom. But this changes the stack layout, and the bottom word is not caller address anymore.

Does this mean information from https://ethervm.io is incorrect, or do I miss something here?

Thanks!


texts: Where does gas comes from when I create a new Contract in a Contract

texts:
Let's say I am creating a contract from another contract by calling a function in a parent contract, is the gas required to create new contract included in running the function that creates new contract?

pragma solidity ^0.4.15;

contract Test {
    bool public active = true;
    address public owner;
    address public contract_address;

    uint public amountReceived;

    address[] public activeContracts;
    uint256 public gasLeft;

    function () payable {
        amountReceived = msg.value;
        gasLeft = msg.gas;
    }

    function Test() {
        owner = msg.sender;
        contract_address = this;
        gasLeft = msg.gas;
    }

    function updateStatus() {
        active = false;
    }

    function kill() {
        selfdestruct(owner);
        gasLeft = msg.gas;
    }

    function createSubContract() {
        address newContractAddress = new SubTest();
        activeContracts.push(newContractAddress);
        gasLeft = msg.gas;
    }
}

contract SubTest {

    address public owner;
    address public contract_address;

    uint256 public amountReceived;
    uint256 public gasLeft;

    function () payable {
        amountReceived = msg.value;
        gasLeft = msg.gas;
    }

    function SubTest() {
        owner = msg.sender;
        contract_address = this;
        gasLeft = msg.gas;
    }

    function kill() {
        selfdestruct(owner);
        gasLeft = msg.gas;
    }

}

Here is a sample contract I am testing. Inorder to create a subcontract I call the function createSubContract, does gas required for calling this function include the gas required to create the contract?


texts: What happens when i redeploy my contract on truffle?

texts: I am very confused by the term 'Contracts are immutable' does it mean when I deploy my contracts, I can't update my code again, and what actually happens when I redeploy my smart contracts after and update to the contract, do I lose all the records?


texts: How much gas is consumed by a smart contract deployment?

texts:
I have a compiled EVM file which is 18,012 bytes large and when placed on the blockchain it creates a contract which is 17,859 bytes large. This size has been checked by running

eth.getCode(contractAddress);

Geth reports that the gas consumed when deploying the contract is 2,156,370. But the Yellow Paper Appendix G Fee Schedule states that the deployment of a contract should be 200 gas per bytes which gives 17,859*200=3,571,800 gas, larger that the 2,156,370 gas reported by geth by running this code:

var rcpt = eth.getTransactionReceipt(submittedContract.transactionHash);
console.log('Gas used: ' + rcpt.gasUsed);

The deployment of the contract (the constructor) also writes to storage so the gas consumed should be even larger. What am I missing?


texts: How do I get a random number on the binance chain in solidity?

texts:
How can I get a random number on binance smart chain in a solidity contract?
I am seeing these articles from binance about chainlink:
https://www.binance.com/en/blog/421499824684901349/New-on-Binance-Smart-Chain-Chainlink-Oracles
And Fetch AI
https://medium.com/fetch-ai/launching-our-random-number-beacon-on-binance-smart-chain-8e3b7aa52be6
But for the life of me I cannot find any documentation of how to use these on the production chain and how much the costs are.
Can anyone shed more light?
Chainlink has this article, but it only talks about testnet not production.
https://docs.chain.link/docs/get-a-random-number
For Fetch-ai, google search returns article after article about the GLOW-DRB, but I cannot find anywhere how to use it. Cannot see anywhere in the Fetch-ai Github or on their developer documentation.
Also really want to know the costs.
Thanks!


texts: How to implement recurrent smart contract without third-party libraries?

texts:
I want to implement an investment service based on ethereum smart contracts in which customers receive dividends four times in a month. For example, a customer receives dividends on 8th, 16th, 21th, and 26th of a month in a recurrent manner.
Is it possible to implement without any third-party services, e.g., AION or Ethereum Alarm Clock?
I was wondering if you help me with this case.


texts: How to limit N bytes to value range using Oraclize Ledger-Proof Random Number -- unfair raffle

texts:
Lets say you have 50 tickets to a raffle. You choose to return 4 random bytes from the ledger proof RNG(https://github.com/oraclize/ethereum-examples/blob/master/solidity/random-datasource/randomExample.sol). The bytes generated can return a number up to 2^(8*4) = 4294967296.

You have 50 tickets -- so the RN’s 4294967251–4294967296 represent a slightly higher chance of winning for ticket holders 1–46 versus a slightly less chance for tickets 47–50. The disparity of fairness is tiny… but non-zero.

Do you know any good solutions to this problem?

1.Discarding the numbers 4294967251–4294967296 has cost value when paying Oraclize.

edit: So to clarify I am completely convinced by the tinyness of the disparity between tickets in this case and when using the full 32 bytes. However, I neglected to mention I feel the need to accommodate a 'laymens perspective' (There is lottery for who gets to go to Mars, and my ticket has miniscule chance less than my neigbours ticket of getting to go -- I am a laymen and don't really understand statistics, bias, etc... all I understand is that my neighbour gets one more chance in 10 googleplexes than me to go). So it seems like rejection sampling is the only way. But it means I have to code for making multiple calls vs adapting the random bytes somehow.


texts: Is it possible to trigger a function from my smart contract whenever anyone will be send ether to a specific address from any kind of wallet?

texts:
I am developing a donation app,Where I have a specifications whenever anyone will be donate to a specific account then a email will be sent to a specific email address.That ether can send from personal wallet of sender also.
1. Is it Possible to trigger a function whenever a payment received and then how ?
2. should i use the deployed contract address as the vault address to send or i can give hard coded address to send money?


texts: Would it possible to propose converting most of The DAO's stake to Digix Gold?

texts: Suppose that the majority of the stake holders of The DAO decide having a 100% ETH stake is risky due to its volatility. Would it be possible to propose converting, say, 50% of The DAO's stake to Digix GOLD, in order for the company to have a more stable reserve? And, obviously, move it back to ETH on demand?


texts:
I relatively new to mining in general and I only want to explore what it is like to mine (I'm not really crazy on building rigs or anything but I just want to know the vast ocean of knowledge about mining for ether).

I used my GPU to run some simple hashes and I'm not 100% on the payout. I'm using this mining pool: https://ethermine.org/

On the website, it says that it pays out every 1 ether. So does that mean once I get to 1 ether within that pool, it'll be transferred to me? Or does it mean the entirely of the pool?


texts:
so I have the following function in my smart contract:
 function proxy(address target, uint value, string memory signature, bytes memory data, uint eta) public returns (bytes32) {

        callData = data;
        (bool success, bytes memory returnData) = target.call.value(value)(callData);
        ...
    }

This function is just a proxy that calls another function in another smart contract, that function accepts many parameters.
This is my web3
 const txHash = await timelockContract.methods.proxy("0xF759Deb538aeEe26842b2cf37a9eB5A3687f8f23",
    0,
    "otherFunctionInOtherSmartContractfunctionCall(uint256, uint256)",
    BYTES PARAMETERS,
    1618335100
    ).send({from: "0x8077931197c1F0a1047c1d066d937931EAB4C5Dd"});

So, where 'BYTES PARAMETERS' is, goes the parameters for the function, so I have to send 2 parameters as bytes, but I dont find a way, from what I've read, you can convert to bytes using the following function:
web3.utils.asciiToHex()
But how can I send two parameters or more as bytes?


texts: (C#) How to transfer funds from myetherwallet to coinbase

texts:
I need to transfer funds from myetherwallet to coinbase.
I looked at https://infura.io/ and https://developers.coinbase.com/ and https://nethereum.readthedocs.io/en/latest/introduction/web3/#properties-methods-overview but so far no luck.
Can you please point me to the resource for it.


texts: Is there a form of mapping with an even larger space?

texts:
I understand from here that the space for mapping() is drawn from a size of 2^256 * 32 bytes storage, which provides a 1 chance in 10^69 of overwrites.  If I'm working with contracts on the order of 10^100, is there a bigMapping() function that could be used for bigger map spaces?

I'm imagining an implementation like this https://mikemcl.github.io/bignumber.js/ for arbitrary precision.


texts: Private network, contract testing - iterate through addresses and repeat function calls

texts:
I'd like to test a contract using ~100s of different accounts. To start with I'd like to encapsulate contract interactions with successive addresses in a for loop. For argument's sake, using this contract:

contract UnitCounter {
    mapping (address => uint256) public UnitsFrom;
    uint256 public TotalUnits;

    function submitUnits(uint256 Units) {
        UnitsFrom[msg.sender] = Units;
        TotalUnits += Units;
    }
}

They way I imagine doing this is with the following pseudo code (where abi is from above):

var MyContract = web3.eth.contract(abi)
var myContractInstance = MyContract.at('0xE522E4A145f345925c80C5Cf4b67a5fa00304875')
var randnumberlist = [4,5,1,3,8,7,2,8,9,9,2]
for (var x = 0; x < 10; x++){
    personal.newAccount("pword")
    rand=randnumberlist[x]
    personal.unlockAccount(eth.coinbase,"coinbasepword",300)
    eth.sendTransaction({from: eth.coinbase, to: eth.accounts[personal.listAccounts.length-1], gasPrice: "1000"})
    personal.unlockAccount(eth.accounts[personal.listAccounts.length-2],"pword",300)
    var randnumberlist = [4,5,1,3,8,7,2,8,9,9,2]
    myContractInstance.submitUnits(rand, {from: eth.accounts[personal.listAccounts.length-1], gas:3000000})
}

Is it possible to achieve loops like the above using the geth javascript console? If not, could I use the geth command line options with a loop implemented on the OS command line?

Looking at the docs it seems this is not possible. How else might I achieve it?

EDIT:

I think I've almost managed (code amended). However I'm now getting this error:

ReferenceError: 'MyContractInstance' is not defined
    at <anonymous>:10:1

Possibly I need to wait for the transaction to be mined first.


texts: testrpc - how to write commands in console?

texts:
I have started testrpc with the following command (which should give the account a balance of 1000):

testrpc --account="0x0116af719d217c12310c72c27a13509f192588735ae329f7c4cfef0e1518955e,1000"

Testrpc then starts up as expected:

  EthereumJS TestRPC v3.9.2

  Available Accounts

  (0) 0x7a9a73cf766ec8340e41b0755691b0503947d982

  Private Keys

  (0) 0116af719d217c12310c72c27a13509f192588735ae329f7c4cfef0e1518955e

  Listening on localhost:8545

Then I want to write a command to query the balance of this account. However, if I write something like eth.getBalance("0x7a9a73cf766ec8340e41b0755691b0503947d982") (which is what works when connected to a private blockchain with geth, for example) or anything else in the same command prompt window nothing happens - it just goes to a new line.


texts: Problems accessing my funds with Ethereum Wallet 0.3.9

texts:
Unfortunately, I have a problem before me. I have on my computer the wallet "Ethereum-Wallet-win64-0-3-9" I have updated recently. On this wallet there is a "contract address" linked to an "account address" in the same wallet that I own. Unfortunately I don't know by which process it took place. I would like to know if there is a solution to get back my 266 ether. Maybe it is possible to re-transfer the ether of "contract address" to "contract creator address". Thank you in advance for your problem. I hope to receive a response from you. Yours

Here is my account Address:] Here is my contract address:]

I am the holder of the private key of the contract creator address and the private key of the account address.

What should I do to get my ether?


texts: pyethapp ImportError: cannot import name blocks

texts:
I installed pyethapp using pip install -c constraints.txt pyethapp.  The constraints.txt file has one line, pyelliptic==1.5.7, to prevent the install error mentioned in this thread.  The install succeeded, but when I run pyethapp I get the following error:

File "/home/ubuntu/pyethapp/pyeth-venv/bin/pyethapp", line 7, in <module>
  from pyethapp.app import app
File "/home/ubuntu/pyethapp/pyeth-venv/local/lib/python2.7/site-packages/pyethapp/app.py", line 2, in <module>
  from ethereum import blocks
ImportError: cannot import name blocks

I went looking for the blocks module in python2.7/site-packages/ethereum and found the file block.py.  It appears as if the module was renamed, or that pyethapp was built for a different version of pyethereum.

The versions I'm installing (by default) are:

ethereum==2.0.4
pyethapp==1.5.0

Are these versions incompatible?  Can I fix the error by installing different versions? Is there another way to fix the error (with modifying the source code)?


texts:
I am going to get past events which are only confirmed using web3.
In tronweb, we can get by specifying onlyConfirmed parameter in getEventResult function.
this.tronWeb.getEventResult(CONTRACT_ADDR ,eventName:'EVENTNAME',size: 1, onlyConfirmed: true});

But how can I get only confirmed events using web3.js
Thanks.


texts: Calling Truffle Commands through a script

texts:
I made following contract using visual studio code

pragma solidity ^0.4.17;

contract IDSCheck {

    mapping( string => string ) PersonHash;

    function AddHash(string name, string hash) {
        PersonHash[name] = hash;

    }

    function GetHash (string name) public returns (string) {
        return PersonHash[name];
    }
}

Now I want to call this function from truffle using exec command.

I wrote a js file named idscheck.js with the following commands

var IDSCheck = artifacts.require("./IDSCheck.sol");
module.exports = function (deployer) {
  var ss;
  IDSCheck.deployed().then(function(deployed){ ss=deployed; });
  ss.GetHash.call("sal");
}

I get an output error saying

  Type Error: cannot read property 'GetHash' of undefined at .....

I am trying to do this is in truffle console.
Primary target is to create a script that runs through a batch file using truffle console to get output of the GetHash function of the above contract.


texts: Size limit to number of items in a struct

texts:
If I loop over mapping into a struct the gas fee is very low. However, in trying to test its limits, the EVM often causes Remix to crash in creating edge cases, because I'm creating blocks of 50 new structs. It does not crash on the loop where I read data and do some algebra, however, and in practice new structs would be added one at a time.

For example, I find that I can basically get to a loop that runs through 7000 items if I extrapolate from a mapping with 200 structs. However, given Remix is often crashing, and it takes a long time to run this loop (seemingly more than proportional to the gas), I wonder if in practice I should lower my estimate of the maximum set of struct members some percentage.

The basic idea looks something like this:

mapping(bytes32 => Contract) public contracts;
bytes32[] public customerContracts;
uint public totalBalance

struct Contract {
    address customer;
    uint inventory;
}

function totalInventory()
public
{
 uint temporaryBalance;
 for (uint i = 0; i < contracts.length; i++) {
     Subcontract storage k = contracts[customerContracts[i]];
     temporaryBalance += k.inventory;
 }
 totalBalance = temporaryBalance;
 }


texts: Solidity contract does not update variable when calling it from web3.js

texts:
my solidity code compiled using solcjs
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.4;
contract FirstContract {
  int count = 0;
  function incr() public{
    count = 15;
  }
  function decr() public{
    count = 10;
  }
  function display() public view returns (int){
    return count;
  }
}

Compiled the aboove code in counter.js using node counter.js
const fs = require('fs');
const Web3 = require('web3');
const web3 = new Web3('http://localhost:8545');
const bytecode = fs.readFileSync('build/counter_sol_FirstContract.bin');
const abi = JSON.parse(fs.readFileSync('build/counter_sol_FirstContract.abi'));

(async function () {
  const ganacheAccounts = await web3.eth.getAccounts();
  const myWalletAddress = ganacheAccounts[0];

  const myContract = new web3.eth.Contract(abi);

  myContract.deploy({
    data: bytecode.toString()
  }).send({
    from: myWalletAddress,
    gas: 5000000
  }).then((deployment) => {
    console.log('voting was successfully deployed!');
    console.log('voting can be interfaced with at this address:');
    console.log(deployment.options.address);
  }).catch((err) => {
    console.error(err);
  });
})();

And finally my html
<!DOCTYPE html>

  <title>First DApp</title>

  Increment
  <button id="incr">+</button>

  Decrement
  <button id="decr">-</button>

Basically trying to run a counter using solidity but it is not updating for some reason


texts: is there any way to have a permanent refund contract for ERC20 tokens?

texts:
Im a newbie when it comes to Ethereum but from what I gather, there is a type of crowdsale where if the goal is not met, the investors can send back their tokens and get a refund. However, this is dependent on Goal levels and time limits.

Is there any way that I can create a permanent refund contract for investors? Where at any time, they can send back any amount of tokens up to the amount they purchased, for a refund of that ethereum. I plan on keeping all of the ethereum from investors specificaly set aside for refunds for them, at least for an extended time period of a year or more.


texts: Best practices to calling owner only functions from a website

texts:
I am following the web3 documentation and I found that its possible to sign a contract and do a transaction directly from web3.

I want to call an onlyOwner function in my contract directly from a web page. I am looking for best practices as to where to store the private key and how to go by interacting with the contract securely?


texts: Has web3.eth.getAccounts() changed in metamask?

texts: Has web3.eth.getAccounts() behavior changen when using MetaMask?  I remember it used to return a full list of available accounts, but now it looks like it only returns array of length 1 - the current selected account.


texts: evm_revert to snapshot#1 in ganache-cli automatically

texts:
I am using evm_increaseTime in my tests to move block time but in ganache-cli it shows that it is reverting to snapshot #1.
 I have not used evm_revert or evm_snapshot.

Is it normal?
what is the reason behind it?


texts: Is it possible to access Ethereum API via the browser?

texts: How do you access the api's of ethereum via the browser? Say I wanted to make a one page app that updates every 1 minute with the block number. And where can I get a list of all the API variables?


texts: Is there any limitation for the number of threads to service RPC calls?

texts:
Bitcoin has the config. How about ethereum? (geth)

https://en.bitcoin.it/wiki/Running_Bitcoin

-rpcthreads=<n> Set the number of threads to service RPC calls (default: 4)


texts:
I can run geth console to get a command line interface spawned after launching geth. Similar also works for eth.

I tried parity console but that didn't work out.

 ~ $ parity console
Invalid arguments.

Usage:
  parity daemon <pid-file> [options]
  parity account (new | list) [options]
  parity [options]

Is there anything like that available for parity?


texts: Is this balance splitter contract correct?

texts:
I wrote a simple contract to split balance into 2 addresses. I made a separate withdraw function because I want to use these for mining rewards and unclear if the default function would get called on a mining reward "deposit". (Would it?)

pragma solidity ^0.4.0;

contract SplitBalance{

    address a1;
    address a2;

    function SplitBalance(address _a1, address _a2) public{
        a1 = _a1;
        a2 = _a2;
    }

    function withdraw() public {
        uint money = this.balance;

        //only withdraw in even amounts to avoid rounding loss
        if (money % 2 == 1)   //money is an odd number, make it even
           money = money - 1; //don't worry, it will stay in the balance for next time

        a1.transfer(money/2);
        a2.transfer(money/2);
    }

    function updateAddress1(address newAddress) public {
        if(msg.sender != a1)
           revert();
        a1 = newAddress;
    }

    function updateAddress2(address newAddress) public {
        if(msg.sender != a2)
           revert();
        a2 = newAddress;
    }

    //fallback function that allows ether to be sent to it
    function() payable public { }
}


texts: How to update value on ethereum blockchain without metamask?

texts:
pragma solidity 0.4.24;

contract UniToken{
    string value="Hello";

    function set(string x) public {
        value = x;
    }
    function get() public view returns (string) {
        return value;
    }
}

.

contract.methods.set(newValue)
.send({ from: "My Ether Address"
})

In the above code, i am using my ether address but its responding with error

"Returned error: unknown account"


texts: Using remix and cannot get this to compile. please help

texts:
pragma solidity ^0.8.0;

    import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";

    contract y is ERC20  {
        constructor(uint256 initialSupply) public ERC20("y", "y") {
            _mint(msg.sender, initialSupply);
        }

    }


texts: How to keep track of your smart contracts without a centralized server? Let’s say I have a dapp that creates smart contracts. Is there a way I can keep track of all the smart contracts my dapp has made without relying on a centralized database to store their addresses?


texts: truffle migrate Error: "Cannot find module 'truffle-expect'"

texts:
I'm following a solidity tutorial right now and I'm currently encountering an error when I run truffle migrate. Also, testrpc is running in another terminal tab, so this issue is unrelated to the others on here.

I run truffle init and then add my HelloWorld.sol smart contract to the contracts folder.

pragma solidity ^0.4.11;

contract HelloWorld {
    uint public balance;

    function HelloWorld(){
        balance = 1000;
    }
}

I then run truffle compile and everything works fine

Compiling ./contracts/ConvertLib.sol...

Compiling ./contracts/HelloWorld.sol...

Compiling ./contracts/MetaCoin.sol...

Compiling ./contracts/Migrations.sol...

Writing artifacts to ./build/contracts

I then added the following to my 2_deploy_contracts.js migration file

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

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

However when I run truffle migrate I receive the following error:

Error: Cannot find module 'truffle-expect'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:85773:14)
    at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:21:30)
    at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:59914:15)
    at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:21:30)
    at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:201851:15)
    at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:21:30)

I've tried npm installing truffle-expect but that doesn't seem to work either... Any thoughts?


texts:
I have a function where I am trying to compare the values of 2 mappings. However, I am receiving an invalid opcode error. Which has me confuzzled because I already set the values of both the mappings before calling the function. I think the issue is that the values of the mappings were not saved to the storage section of my contract on Ganache. Does the latest version of Ganache not support mappings?
For context, this is how I am initializing the mappings:
mapping(address => uint) public mapping1;
mapping(address => uint) public mapping2;

And this is how I am setting the values of the mappings:
function setMapping1() public payable {
    value = 5000;
    mapping1[msg.sender] = value;
  }

function setMapping2() public payable {
    value = 10000;
    mapping2[msg.sender] = value;
  }


texts: Ethereum Transaction Using cUrl and web3.php, I get a Receipt but the Transaction is not sent to the Network

texts:
This has been doing my head in all day, after wading through and managing to get all my values converted to hex I create and sign the ethereum transaction using the web3p/ethereum-tx library from GitHub. I put in the cUrl request with the parameters to the infura mainet. I get a response with a transaction hash but when I search for it on etherscan and others it does not show up, any ideas what I'm doing wrong?

use Web3\Web3;
use Web3p\EthereumTx\Transaction;

$balance = bcdiv($balanceInWei, "1000000000000000000", 18);
$gasTotal = 4000000000 * 21004;
$value = bcsub($balanceInWei, $gasTotal);
$gas = dechex(21004);
$gasPrice = dechex(4000000000);

function bcdechex($dec) {
$hex = '';
do {
$last = bcmod($dec, 16);
$hex = dechex($last).$hex;
$dec = bcdiv(bcsub($dec, $last), 16);
} while($dec>0);
return $hex;
}

$hexValue = bcdechex($value);
$nonce = time();
$hexNonce = dechex($nonce);

echo $wallet_address;
  // with chainId
  $transaction = new Transaction([
      'nonce' => '0x'.$hexNonce,
      'from' => $wallet_address,
      'to' => '0xMyWalletAddress',
      'gas' => '0x'.$gas,
      'gasPrice' => '0x'.$gasPrice,
      'value' => '0x'.$hexValue,
      'chainId' => 1,
      'data' => '0x0'
  ]);
  $signedTransaction = $transaction->sign($databaseContainer->private_key);

  $url = "https://mainnet.infura.io/v3/MyApiKey";
  $data = array(
          "jsonrpc" => "2.0",
          "method" => "eth_sendRawTransaction",
          "params" => array("0x".$signedTransaction),
          "id" => 1
  );
  $json_encoded_data = json_encode($data);

  var_dump($json_encoded_data);

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_POSTFIELDS, $json_encoded_data);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
          'Content-Type: application/json',
          'Content-Length: ' . strlen($json_encoded_data))
  );

  $result = json_decode(curl_exec($ch));
  curl_close($ch);
  dd($result);

dd is just me dumping the result in larvel. Thanks in advance.


texts: Cannot withdraw token with openzeppelin postdelivery

texts:
I'm deploying either token and crowdsale without problems, the crowdsale contract its based on the openzeppelin PostDeliveryCrowdsale.

Crowdsale:

contract PorrolhoTokenCrowdsale is PostDeliveryCrowdsale {

    constructor(uint256 _openingTime, uint256 _closingTime, uint256 _rate, address _wallet, uint256 _goal, ERC20 _token) public
    Crowdsale(_rate, _wallet, _token)
    TimedCrowdsale(_openingTime, _closingTime)
    {

    }

}

PostDeliveryCrowdsale:

contract PostDeliveryCrowdsale is TimedCrowdsale {
  using SafeMath for uint256;

  mapping(address => uint256) public balances;

  /**
   * @dev Withdraw tokens only after crowdsale ends.
   */
  function withdrawTokens() public {
    require(hasClosed());
    uint256 amount = balances[msg.sender];
    require(amount > 0);
    balances[msg.sender] = 0;
    _deliverTokens(msg.sender, amount);
  }

  /**
   * @dev Overrides parent by storing balances instead of issuing tokens right away.
   * @param _beneficiary Token purchaser
   * @param _tokenAmount Amount of tokens purchased
   */
  function _processPurchase(
    address _beneficiary,
    uint256 _tokenAmount
  )
    internal
  {
    balances[_beneficiary] = balances[_beneficiary].add(_tokenAmount);
  }

}

I can buy tokens, but when i call the withdrawTokens() function its throwling a error. The balances mapping of the crowdsale contract returns the token amount that i already buyed.

Any idea will be appreciated!


texts: Gas Requirement for Ethereum Message Signing

texts: Is Gas required to sign a message using ethereum?


texts:
I got an error at sendSignedTransaction is : Project ID is required.
Can you please let me know that what is the actual problem?

This is my code:

try {
    const ethereumUri = 'https://ropsten.infura.io/API_KEY'; //process.env.API_URL

    var web3 = new Web3(new Web3.providers.HttpProvider(ethereumUri));

    const keystore = web3.eth.accounts.encrypt(req.body.privateKey, 'Drc@1234');

    const privateKey = new Buffer.from(req.body.privateKey.substr(2), 'hex')

    const decryptedAccount = web3.eth.accounts.decrypt(keystore, 'Drc@1234');

    var amount = web3.utils.toWei(req.body.transaction_value.toString(), "ether");

    var fee_eth = req.body.transaction_fee * 1000000000;
    var convertTOGwei = fee_eth / 21000;
    var decimalLimit = convertTOGwei.toFixed(2);
    var fee = web3.utils.toWei(decimalLimit.toString(),'gwei');

    var sender = req.body.from_address;
    var receiver = req.body.to_address;

    /*var rawTransaction = {
        "from": sender,
        "to": receiver,
        "gasPrice": web3.utils.toHex(fee),
        "value": web3.utils.toHex(amount),
        "gas": 21000,
        "chainId": 3
    };*/

    const txCount = await web3.eth.getTransactionCount(sender)

    // Transaction
     const txObject = {
        nonce:    web3.utils.toHex(txCount),
        to:       receiver,
        value:    web3.utils.toHex(amount),
        gasLimit: web3.utils.toHex(21000),
        gasPrice: web3.utils.toHex(fee)
     }

    // Sign the transaction
    const tx = new Tx(txObject, { chain: 'ropsten', hardfork: 'istanbul' })
    const pk = Buffer.from(privateKey, 'hex')
    tx.sign(pk)

    const serializedTx = tx.serialize()
    const raw = '0x' + serializedTx.toString('hex')
     // Broadcast the transaction
    const receipt = await web3.eth.sendSignedTransaction(raw)
    return receipt;
} catch (e) {
    console.error(`try/catch Error:(${e})`);
}


texts: How do I find the deployed contract address for CryptKitties?

texts:
I read some version of the CryptoKitties source code on https://github.com/axiomzen/cryptokitties-bounty

How do I use information only on https://cryptokitties.co, and preferably inside MetaMask, to determine the actual address of the deployed KittyCore contract.

To be clear, some blogger has told be that this is what I am looking for: https://etherscan.io/address/0x06012c8cf97bead5deae237070f9587f8e7a266d#code However anybody could have deployed that. I am looking to determine which one is actually running behind https://cryptokitties.co.


texts: Should uncles factor into average network block time and difficulty calculations?

texts:
It's unclear to me if uncles should factor into averages like block time and difficulty.

The fact that they are associated with a parent block and have a timestamp and difficulty, leads me to believe that since there was work done for them that they should possibly factor in.

On the other hand, since they are not technically considered to be a part of the longest chain and are intended to serve as extra incentives for the miner(s), I'm wondering if they should really be considered?

Can anyone provide some clarity one way or the other as to whether or not they should factor into the aforementioned calculations?  Thanks.

Edit: To further clarify, I am not asking in the context of whether they should factor in to the actual network's difficulty adjustment calculations.

But rather, should they factor into something like a blockchain explorer's approximate difficulty and hashrate calculations?

Logically, it seems they should be included since there was actual work done for them and to exclude them, would be failing to account for work that was actually done.  On the other hand, nearly identical work was done on the block that ended up being accepted by the network over the uncle.

Given that, should uncles simply be excluded from all such blockchain-type analysis calculations such as average network difficulty and hashrate over a given period of time?


texts: why my Contract address 0 value on etherscan

texts:
Transaction Hash:
0xcacbecb6c8be10317e27784c7afd33fa52f43df6e31fcc4e0a253b274201bc56
Address
0x1B2cB9A600F80D8cDb529F8D448b9010B0C978c6


texts: invalid bytes32 value - Maker Contract Call

texts:
I am trying to call the Maker CDP Contract manager smart contract.

I want to get the information from this public mapping in the contract.

mapping (bytes32 => Cup)  public  cups

and should return a mapping:

    struct Cup {
        address  lad;      // CDP owner
        uint256  ink;      // Locked collateral (in SKR)
        uint256  art;      // Outstanding normalised debt (tax only)
        uint256  ire;      // Outstanding normalised debt
    }

Where bytes32 should be a bytes representation of the CDPId.  They have a python implementation that passes a value to this mapping from a function that looks like this.

def int_to_bytes32(value: int) -> bytes:
    assert(isinstance(value, int))
    return value.to_bytes(32, byteorder='big'

I've tried this:

myContract.methods.cups(web3.utils.fromAscii("5")).call(
    function (err, res){
        console.log(res)
    }
)

However, I cannot figure out for my life how to pass the proper ID of say 5 to the bytes32 mapping and return the proper output.  Everything returns with 0's even though I know that is incorrect.

Any help is appreciated.


texts:
I want to try to mine ethereum.
Its only a Test if it's working.
I am new to Ethereum. I am only mining Bitcoin.

So I installed the ethereum miner.

And want to mine in the f2pool.
In the help "Simply point your stratum-compatible miner to zec.f2pool.com:3357, eth.f2pool.com:8008 or etc.f2pool.com:8008, and set your ethereum account as login"

So I tried (my username is wiraport) whats about the password

ethminer -F http://etc.f2pool.com:8008/wiraport -C -t 4

I got the following error.

  13:05:58.486|ethminer  Getting work package...   ✘
  13:05:58.981|ethminer  Failed to submit hashrate.   ✘
  13:05:58.981|ethminer  Dynamic exception type:
  jsonrpc::JsonRpcException std::exception::what: Exception -32003 :
  Client connector error: libcurl error: 56

Whats that and how can I fix it?


texts: How of should I migrate my Smart Contract?

texts: I am developing a scraper which scrapes data and puts it on ethereum blockchain(ganache for dev) every week. So as to put this data onto the blockchain should I migrate my smart contract each time I am updating the data?


texts: Check if the web3 provider supports certain rpc call

texts:
For example, when I am using:

web3.currentProvider.sendAsync({
                method: "eth_signTypedData_v3",
                params: [customerAddress, data],
                from: customerAddress,
                id: new Date().getTime()
        }

I would like to know if eth_signTypedData_v3 is supported by the web3 provider before I invoke it.


texts: I am trying to add ether to one of my ethereum account using smart contract

texts:
function Execution (address _from, address _to) {
        _from.transfer(price);
        _to.getBalance(_to) += price;
    }

1) I think it is duplicate but i gone through  but nothing helped

2) I want to add money to to account which is deducted from  from account
plese help me

3) I tried

  _to.value()

also to add  but nothing helped


texts: How to make Truffle tests run separately without contaminating state

texts:
I have a test contract with four test functions. Using truffle compile && truffle test.

If I run it as normal, functions 1-3 pass and #4 fails.

If I commend out function #2 then functions 1, 3, 4 all pass.

It is clear that the test functions are not being run independently. How do I make my test functions run independently or otherwise compensate for this situation?

My test cases are all in one Solidity file.


texts:
My questions:

Are MyEtherWallet and Ethereum Wallet same?
Is it possible to keep multiple crypto currencies including  bitcoin, Ethereum and others in a single wallet? Or do I need separate wallets for each crypto currencies?


texts:
As someone more familiar with bitcoin than ethereum I'd like to ask what would be the best way to accept ETH payments as a merchant? With bitcoin I can do following and my question is if it makes sense also with ETH or what needs to be done in a different way?

Generate a new address from seed using BIP44 m/44'/60'/0'/0 (is this standard/supported?)
let the customer send ETH to this address
periodically check blockchain for the address balance
confirm payment if the amount matches

Will the merchant be able to use the seed to collect all the incoming payments and send them to a single address later for example? Would they be able to do it using Metamask, MyEtherWallet or Trezor?
How would this be different with ERC-20 tokens?
Imagine you generated a few addresses (as above) and customers paid USDT - each customer / payment to a new address.

Now the addresses only have USDT and no ETH, right?
Is ETH in each of the wallets needed to pay for gas to send it from there? Or could you pay the gas from the "shared" HD wallet in any way?
Can the merchant make a single transaction collecting all the balances from all the addresses and send it somewhere?


texts: Why is this value 0? Weird behaviour of my smart contract

texts:
I'm stuck with a very weird behaviour of my smart contract.

  uint weiDue = calculateTotalWei(winningBets[i].tokensDeposited, winningBets[i].amounts, multipliers) / totalWeiBetWinningTeam * totalWeiBetLosingTeam;

  //debugging
  weiDueEv(calculateTotalWei(winningBets[i].tokensDeposited, winningBets[i].amounts, multipliers), totalWeiBetWinningTeam, totalWeiBetLosingTeam, weiDue);

The function calculateTotalWei returns uint and both totalWeiBetWinningTeam and totalWeiBetLosingTeam are also uints.

After debugging with event it seems like

  weiDue = 100 / 200 * 1700 // gives 0, should be 850

on the other hand

  weiDue = 100 / 100 * 1700 // gives 1700

What is this magic behaviour and how do I fix this? It seems like 100/200 is coerced to 0 before multipling by 1700 but why?


texts: Command line tool to interact with smart contract

texts:
I want to be able to interact with functions on a smart contract. I do not want to setup my own node using geth, and would like to use something like Infura as a remote node.

Based on what I have seen, one of the more popular options is Web3, but I cannot get it connect to my Infura node. I run the below commands (after opening the NodeJs console using "node"):

Web3 = require("web3");
web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/personalcode"));

Running web3.eth.blockNumber after doing this returns null though. I also see the below in the output after running the require statement:

HttpProvider
    host: 'https://mainnet.infura.io/personalcode',
    timeout: 0,
    connected: false,

The Web3 version is 1.0.0-beta.34 btw (not sure if that has anything to do with it).

Any suggestions or pointers on what I am doing wrong? I am not committed to using web3 btw. Any way to interact using the command line is fine.


texts:
I have been looking for a sniffer similar to Bitcoin P2P Network Sniffer (https://github.com/sebicas/bitcoin-sniffer) which could allow me to connect to Ethereum nodes and listen to blocks and transactions.

Does anybody know such a sniffer?


texts: Can we change the Consensus of Ethereum after cloning from github

texts: If we clone ethereum from Github can we change its consensus like other parameters Gas ,blocksize. like if we dnt want to build Blockchain from scratch is there any way to change the consensus mechanism. which platform is best for it


texts: how the Smart contract decide how much token need to be send on every 1 Ethereum ? didn't found any  which define such function, anyone ?


texts: Reading a uint from a mapping keeps returning a random address

texts:
I am new to Solidity. I am facing an issue in a simple operation of storing and retrieving data from mapping (uint=> address).

I have defined a simple contract:

contract test {
    mapping (uint => address) public testmap;

    function add_to_map  (uint _key, address _val) public{
        testmap[_key] = _val;
    }
    function get_from_map(uint _key) returns (address){
        return testmap[_key];
    }
}

In html, I am trying to do:

function createTestContract(){
    var test = testContract.at("0xc383dfb5fc71ff1bb2bbadb812229681fb7a8e3c");
    test.add_to_map(1, "0x12ca4a043753cd5537af99ad314a299962238ed2");
    console.log('Key: 1'  + ' address: ' + test.get_from_map(1));
}

As output I am expecting address - 0x12ca4a043753cd5537af99ad314a299962238ed2 which I am stored against key 1. However, it is returning some random address in the console log.

Key: 1 address: 0x07824f2f2a330dd2e260437af299800175dc2642a63c71a5f824cee54eae2264

I am using private chain on AlethZero. Appreciate if anyone can help.


texts:
I was working with ethereum using:
- solcjs

web3
truffle
public no firewall kovan node (parity)
and MultiSigWallet.sol from https://github.com/gnosis/MultiSigWallet

And when I checked my wallet in the kovan node, the balance has been transferred to 0x093a0ed738b65ed34f2a37a2d44c5e3cd0d0dd45 on this transaction https://kovan.etherscan.io/tx/0xf33a3a43b7a13dae0d5d83027ec642a6fd383eafe3d0c5f5c6cedb3580ddb59a?

The transfer happened pretty much when I do a curl call to personal_unlockAccount.
Does this transfer because I unlock my account? and there is someone who scanned and auto transfer to 0x093a0ed738b65ed34f2a37a2d44c5e3cd0d0dd45? The wallet seems to have a lot of KETH on the wallet.

Or this might happen because of the third-party tools I'm using mentioned above?


texts: When a new token is issued, how does it get traded if it's not on one the big commercial exchanges? Are all ERC-20 tokens automatically traded on decentralized dapp exchanges?


texts: How do I create an attribute-based access control in my smart contract to control user access and permissions?

texts:
For my Master's thesis, I am trying to create a decentralized file storage system using ethereum, solidity and ipfs. I want to code the smart contract with attribute-based access control but do not have much knowledge on this. Most of the links I have seen so far are of role-based access control.
Could someone please guide me with a few links or a simple code explanation?


texts: MyEtherWallet shows custom token but etherscan does not show any transaction?

texts:
Yesterday I participated in an ICO. I sent ETH to the correct contract adress and my transaction was confirmed. I also found my transaction on  the ICO contract adress via etherscan. I then added a custom token in MyEtherWallet and the correct amount of tokens did show up. So far so good. I checked my token transfers via etherscan but any new transfer is listed. If I check the ICO adress via ethplorer it shows no transfers yet and also only three token holders. How can that be? Why do I see tokens in MyEtherWallet? Do I have the tokens or not?
I am happy about any information.


texts: What is the suggested way to pass in large amounts of data into solidity contract?

texts: If a Member(struct) has 10 fields, the contract stores an array of Members, how would I pass 100 Members worth of data into the contract?


texts: Would a fork require miners to update software it they mine on a pool?

texts:
Would a miner have to update their mining software, such as ethminer, to go on a forked version of the chain? Or is it up to the pool to decide which chain to mine?

Also, if a miner is mining on a pool that chose to stay on the regular chain, is moving to a forking pool the only way to participate in the forked version?


texts: How is gas calculated when running my token's mine function?

texts:
Let's say I have a token contract, which has a mine/pow function (doing some math calculations to find a number/hash) in it. If a user hosts a geth node and runs token.mine(), will those math calculations be counted as gas consumption?

Please help advise, thanks!


texts: How do I access member variables of a contract from web3.eth?

texts:
For example:

enum Stages {
    AcceptingBookings,
    StopAcceptingBookings,
    Finished
}

Stages public stage = Stages.AcceptingBookings;
function rand ( uint256 param) atStage(Stages.AcceptingBookings) returns (uint256){}

In the above, when the contract is in state 'Stages.AcceptingBookings' only code within that function will run, pretty cool..

I just need to be able to access it via web3.eth though and I cant see clear explanation. If anyone knows please let me know
I want to check what stage I am at from web3.eth if it is possible.

The above code is from the Solidity docs on State Machine:
https://solidity.readthedocs.org/en/latest/common-patterns.html#state-machine

Works great from geth, just trying to work out the syntax for web3.eth


texts:
I am looking to move some ETH from an exchange to a wallet for which I control the keys. I don't, however, want to download the whole blockchain.

Is there a good SPV client I can use?


texts: How to build and debug geth with Visual Studio Code?

texts:
Got Visual Studio Code.
Got geth in some folder or other.
Installed go extension to Visual Studio Code.
Installed go tools via Visual Studio Code (including Delve)

Now what? How do I build, run, debug etc?


texts: How metamask restores account information using seed words?

texts:
Metamask don't store keys on any server. Metamask stores your private keys using your browser's data store.

Then how can metamask restores accounts using seed words without storing it anywhere ?


texts: Why can't I map string with address in solidity?

texts:
I want to map names(string) with a wallet address in solidity but solidity throws an error saying that its not allowed!

mapping(string => address) public users;

And this is the error I get:

    TypeError: Dynamically-sized keys for public mappings are not supported.
        mapping(string => address) public users;
        ^-------------------------------------^

Is there any other way to do it?

New here! Suggestions would be appreciated! Thanks in advance!


texts: Understanding of this contract with no "funds transfer"

texts:
I am learning the functionality of the following contract:
https://etherscan.io/address/0xb9955b00fb89456b1a0364cd392e81cd37f6bce8#code

To my surprise, while there are some "transfer" statements which encodes some "notification" regarding an upcoming payment; however, I just cannot find the real call/send/transfer statements that perform the external contract call.

Am I missed anything there? I just cannot imagine a function can have no contract external calls. Any comments or explanations would be strongly appreciated.


texts:
I have a smart contract with a custom token which holds some data. The Token data is defined in a struct and stored in an array:

struct Token {
    string text;
    uint256 value;
}

Token[] public _token;

On my web page I want to display all the tokens of the current user. Therefore I have a function in my smart contract which fetches all tokenIds of the given address. That function is really quick, but when I want to retrieve all Tokens from the Token[] array with the ids I get from the previous function it lasts very long! Especially if the user has many tokens...

To fetch all the tokens of the user I iterate over all tokenIds and perform the following request:

const token= await this.tokenContract.methods._token(tokenId).call();

Does anybody has an idea how to speed up the retrieval?


texts: So I heard that the precompiled contracts perform functions that are difficult to do using EVM opcodes. Does that mean the precompiled contracts are not written in EVM opcodes. Which language are precompiled contracts written in and how are they integrated into Ethereum?


texts: No matching declaration found after argument-dependent lookup in remix IDE

texts:
I'm getting this error in remix:

"TypeError: No matching declaration found after argument-dependent lookup. require(_spender.call.value(msg.value)(_data));
^-----^ "

function approveAndCall(address payable _spender, uint256 _value, bytes memory _data) public payable returns (bool) {
  require(_spender != address(this));
  this.approve(_spender, _value);
  require(_spender.call.value(msg.value)(_data));
  return true;
}

Please I need help on how to resolve this. Thanks


texts: Web3 create account from mnemonic + passphrase

texts:
I'm trying to create an ethereum account using web3-js by providing a mnemonic + passphrase (created with BIP39-js) but can't seem to find an implementation of web3.eth.accounts.create() that accepts both the mnemonic and the passphrase.

Is it not supported or am I missing something on how to implement it?


texts:
I am trying to understand what money loss case the ERC223 standard is trying to solve.

  If you send 100 ETH to a contract that is not intended to work with
  Ether, then it will reject a transaction and nothing bad will happen.
  If you will send 100 ERC20 tokens to a contract that is not intended
  to work with ERC20 tokens, then it will not reject tokens because it
  cant recognize an incoming transaction. As the result, your tokens
  will get stuck at the contracts balance.

I thought this is solved by approve and transferFrom in ERC20? Since contracts that do not accept ERC20 tokens would not user transferFrom in order to fetch the tokens?


texts: Truffle Object Keeps Changing to Undefined When I Try To Play With Data With React

texts:
The question is in the title.  I have a React Component that displays the appropriate data when I do it in a very specific way, but breaks when I try to play with the data.

    state = { dataKey: "1", listAllCompanies: null};

    componentDidMount() {
        const {drizzle, drizzleState } = this.props;
        const contract = drizzle.contracts.PriorIncidents;

        const dataKey = contract.methods["listAllCompanies"].cacheCall();
        this.setState({dataKey})
    }
    render() {
        const {PriorIncidents} = this.props.drizzleState.contracts;
        const listAllCompanies = PriorIncidents.listAllCompanies[this.state.dataKey];

        return (

 List the Companies

Stored companies: {listAllCompanies && listAllCompanies.value}

        )
    }
}

That's the code when it works.  Specifically, it displays the mock data that I have on the chain.  However, if I try to modify anything, it breaks and tells me that listAllCompanies is undefined and I don't understand it.  Even if I try a call to console.log(listAllCompanies) or console.log(listAllCompanies.values) or if I remove the listAllCompanies in the jsx display, leaving {listAllCompanies.value} it tells me that listAllCompanies is now undefined.


texts: Calling smart contract function with web3: this._eth.call is not a function

texts:
i went throught the greeter example in here https://www.ethereum.org/greeter and i deployed the smart contract under ropsten test net.

Now im trying to call it from a web page using web3.

var greeterAddress = '0xbc15fCDef6F6FAbAd4097816006523626c10a685';
        var abi = [{ constant: false, inputs: [], name: 'kill', outputs: [], type: 'function' }, { constant: true, inputs: [], name: 'greet', outputs: [{ name: '', type: 'string' }], type: 'function' }, { inputs: [{ name: '_greeting', type: 'string' }], type: 'constructor' }];

        var greeter2 = new web3.eth.contract(abi).at(greeterAddress);

        console.log('Calling the smart contract');
        var result = greeter2.greet();
        console.log(result);

i keep getting while calling:

var result = greeter2.greet();

the following error:

Uncaught TypeError: this._eth.call is not a function
    at c.call (inpage.js:14300)
    at c.execute (inpage.js:14300)
    at send (ex.html:32)
    at HTMLButtonElement.onclick (ex.html:14)

which step should i take to make sure the contract doen't have any initilization problem?
For what i have seen by looking around at examples this should work without problems.

More info: I have another piece of code sending ETH to an address and works just fine, so web3 should be properly installed (version is 0.2x.x.)

EDIT Final working solution:

 var greeterAddress = '0xbc15fCDef6F6FAbAd4097816006523626c10a685';
        var abi = [{ constant: false, inputs: [], name: 'kill', outputs: [], type: 'function' }, { constant: true, inputs: [], name: 'greet', outputs: [{ name: '', type: 'string' }], type: 'function' }, { inputs: [{ name: '_greeting', type: 'string' }], type: 'constructor' }];

        var greeter2 = web3.eth.contract(abi).at(greeterAddress);

        console.log('Calling the smart contract');
        //var result = greeter2.greet();
        //console.log(result);
        greeter2.greet(function (error, result) {
            if (!error)
                console.log(result)
            else
                console.error(error);
        });


texts: Can smart contracts be used for refundable purchases of physical items?

texts:
I am new to Ethereum and trying to understand what real-world use-cases are there for smart contracts (outside the world of cryptocurrencies).

As an example, suppose a flight company wants to sell a flight ticket with a guaranee that, if the flight is late by more than 3 hours, the ticket will be fully refunded. Or, suppose a person rents his home through AirBNB, with a guarantee that, if the buyer cancels at least a week before check-in, he can get 50% of his money back.
Can such contracts be encoded in Ethereum? Apparently it seems they cannot, since someone has to tell Ethereum that the flight is canceled, or that the rent is canceled. Am I missing something?


texts:
How can i send payments from my ubuntu ethereum node to any address?

Is there any working example, that may help me to get this done?

CODE EDITED

var Web3 = require('web3');
var Tx = require('ethereumjs-tx');
// Show Web3 where it needs to look for a connection to Ethereum.
//web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8545'));
web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/<account-id>'));
var gasPrice = "2";//or get with web3.eth.gasPrice
var gasLimit = 3000000;
var addr = "0x......................";
var toAddress = "0x..............................";
var amountToSend = "0.00192823123348952"; //$1
var nonce = web3.eth.getTransactionCount(addr); //211;
var rawTransaction = {
"from": addr,
"nonce": web3.utils.toHex(nonce),
"gasPrice": web3.utils.toHex(gasPrice * 1e9),
"gasLimit": web3.utils.toHex(gasLimit),
"to": toAddress,
"value": amountToSend ,
"chainId": 41 //remember to change this
};
var privateKey = ".........................................................";
var privKey = new Buffer(privateKey, 'hex');
console.log("privKey  : ", privKey);
var tx = new Tx(rawTransaction);
tx.sign(privKey);
var serializedTx = tx.serialize();
console.log('serializedTx : '+serializedTx);
web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), function(err, hash) {
if (!err)
{
console.log('Txn Sent and hash is '+hash);
}
else
{
console.error(err);
}
});


texts: Starting multiple private network in one computer causes Fatal: Error starting protocol stack: Access is denied

texts:
Question: How to fix Fatal: Error starting protocol stack: Access is denied?

Here is the steps that I try:

geth --datadir block1 init /d/nodes/_ethereum/genesis.json
geth --datadir block1 --networkid 1234 --rpc --rpcport 1201 --rpcaddr 127.0.0.1 --rpccorsdomain "*" console 2>console.log
First node running successfully...
geth --datadir block2 init /d/nodes/_ethereum/genesis.json
I created my new block...
geth --datadir block2 --port 30304 --networkid 1234 --rpcport 1201 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --nodiscover console 2>console.log

I also tried using: --rpcaddr [my current ip address]

This happens when I run the second node:
Fatal: Error starting protocol stack: Access is denied

Windows 10 Home 64bit


texts: raft based consensus for private transaction

texts: According to my understanding, in raft based consensus, leader is the minter who notifies all the follower to add new block in blockchain. In private transaction betweeen two nodes A and B of Quorum, will the leader be from A and B or it can be any node in Network?


texts: Function overriding versus Solidity Compiler Warning: Function state mutability can be restricted to pure

texts:
I have a function in a base contract that could have the state mutability modifier "pure" because it always returns true:

    BaseContract {
        function x(bytes memory)
            public
            view
            returns(bool)
        {
            return true
        }
    }

However, this function is usually overridden in derived contracts, like so:

DerivedContract is Base {
    function x (bytes memory payload)
        public
        view
        returns(bool)
    {
        // do some non-pure stuff
        // return true OR false
    }
}

My question regarding how to silence this compiler warning is rooted in
deeper questions:

Does function overriding in Solidity still work, even if the
to-be-overidden function has a non-identical state mutability
modifier?
Therefore, can I change the state-mutability modifier of the base
function to pure, and still have this function overridden, or will
the two dissimilar state mutabilities (view vs. pure), all else
being identical, result in some sort of function overloading?
If overriding a function with a dissimilar state mutability does not
work, how can I silence the aforementioned compiler warning?

Thanks for your help!


texts: How to access an account if node is down

texts:
Consider a following scenario for a multi node private blockchain network:

If one node is down, how can I access accounts created on that node from another node without having private key of the account?

OR

If one node is down, how can I access accounts created on that node from another node as the private keys are residing on the node which is down?


texts:
I bought a very small amount of ETH on coinbase just to try it, and I wanted to create my own wallet to get it out.

However, I've been trying to get Mist working for 3 days and it is always stuck on some step: not connecting to peers, the blocks stuck without downloading, chain structures increasing faster than my computer can download them, and crashing my admittedly modest Intel i5 @ 2.80 GHz/ 6 gb RAM computer.

I'm aware I can just launch the application and get an account, but shouldn't it work all the way? Does it matter that I can never sync completely?

I can also just use myetherwallet but I really wanted the official recommended desktop app to work. I don't want to disparage ether and I'm really glad that my ETH revaluates every day or almost every hour, but how do you expect widespread acceptance if the official app appears not to work?

I hope this post doesn't get flagged as "pointless", and that someone can really explain if I'm doing or understanding something wrong here.

Thanks in advance.


texts: solidity-coverage adds extra events which make unit-test fail

texts:
It seems that when using the latest solidity-coverage (0.5.11), truffle (5.0.0-next.25) ganache-cli (6.2.4-beta.1) and solc (0.5.0) additional events / logs are emitted during tests which make the unit-tests fail.

My test code was like:

it('addSupplier', async () => {
        // Act
        const result = await contract.addSupplier(supplier1, 'Supplier 1');

        // Assert
        assert.lengthOf(result.logs, 1);

        const log = result.logs[0];
        assert.isNotNull(log);

        const event = log.event;
        assert.equal(event, 'AddSupplierEvent');

        const eventArgs = log.args;
        assert.isNotEmpty(eventArgs.from);
        assert.isNotEmpty(eventArgs.id);
        assert.equal(eventArgs.id, supplier1);
        assert.equal(eventArgs.name, 'Supplier 1');
});

And I expected 1 event to be submitted : AddSupplierEvent, however the output shows:

Events emitted during test:
[Coverage]     ---------------------------
[Coverage]
[Coverage]     __FunctionCoverageSupplyChainLogContract(fileName: C:/.../contracts/SupplyChainLogContract.sol, fnId: 1)
[Coverage]     __CoverageSupplyChainLogContract(fileName: C:/.../contracts/SupplyChainLogContract.sol, lineNumber: 9)
[Coverage]     __StatementCoverageSupplyChainLogContract(fileName: C:/.../contracts/SupplyChainLogContract.sol, statementId: 1)
...
[Coverage]     AddSupplierEvent(from: 0xd721da73Adf6AfBFfaC15A8a4Bae662D5D02c351, id: 0x8caa8760a712e9E96868314Bc59711094BAB263E, name: Supplier 1)

Is this by design ?


texts: What happens to a transaction with an invalid signature?

texts:
Understand VRS is the output of ECDSA. Not many will use ecrecover() to check for the signature.

How does the public ethereum network handle an invalid transaction signed with an invalid private key? What happens to the transaction? Will it be propagted and/or recognised by majority of the nodes or rejected?


texts: Does sendRawTransaction behave the same as sendTransaction with nonce parameter.

texts:
In the Javascript API wiki it states that if you send a transaction with sendTransaction() and the optional nonce parameter set you can overwrite your pending transaction.

  nonce: Number - (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.

In my code I am using sendRawTransaction() and if I set the nonce to the same as my last tx while it is still pending it bounces and never gets accepted to the pool. Is this what should be expected for sendRawTransaction?

I am re-signing the transaction each time with the same/previous nonce. I get a txid returned but after many attempts it has never overwritten the tx and I can never get working txid.

Is this the expected behavior?

I am having trouble using web3.eth.pendingTransactions it always returns an empty array. So i cant use eth.resend(web3.eth.pendingTransactions[0], newGasPrice). Ultimately my goal is to overwrite a transactions with a higher gas price when certain conditions are met.


texts: Ethereum storage - how does this cost happen?

texts:
contract A {

    uint x = 10;

    function test2() public {
        x = 0;
    }

}

I can see that:

Transaction cost is 13204
Execution cost is 5136

How can this be ? I calculate differently.
Those 3 are taken from white paper.

Paid for every transaction - 21000
Paid for an SSTORE operation when the storage value’s zeroness remains unchanged or
is set to zero. - 5000
Refund given (added into refund counter) when the storage value is set to zero from
non-zero - 15000

So, 21000 + 5000 - 15000 = 11000. How did we get 13204 ?


texts: Contract method works only with contract addresses and not regular account addresses

texts:
I've written a simple token contract for testing purposes:

pragma solidity ^0.4.18;

contract TestToken {
    uint public totalSupply;

    mapping(address => uint) public balanceOf;

    function transfer(address to, uint amount) public returns (bool) {
        require(balanceOf[msg.sender] >= amount);
        balanceOf[msg.sender] -= amount;
        balanceOf[to] += amount;
        return true;
    }

    function credit(address to, uint amount) public {
        balanceOf[to] += amount;
        totalSupply += amount;
    }

    function debit(address from, uint amount) public {
        balanceOf[from] -= amount;
        totalSupply -= amount;
    }
}

Whenever I call the credit method on the contract and pass the address of another contract as parameter, everything works as expected:

token.methods.credit(wallet._address, 500000).send({from: accounts[0], gas: "0xB3E4", gasPrice: "0x4A817C800", value: "0x"})

The status of the transaction is 0x1.

The balance is updated:

token.methods.balanceOf(wallet._address).call()
'500000'

But when I pass the address of a regular ethereum account as a parameter, the transaction gets mined, but nothing happens.

token.methods.credit(accounts[0], 500000).send({from: accounts[0], gas: "0xB3E4", gasPrice: "0x4A817C800", value: "0x"})

The status of the transaction is 0x0.

The balance doesn't change:

token.methods.balanceOf(accounts[0]).call()
'0'

Comparing the resulting signed transaction objects, the only difference other than the data field is that the signature v value is always 0 when the transaction fails and 1 when the transaction succeeds. But I'm not sure what that means.

Update:

Seems like it's not even contract vs non-contract, it's just that some addresses don't work.

For example, this works:

token.methods.credit('0xd2d0aD819B2679FBDD5C75F93fa13242bfd7E2A5', 500000000000000000).send({from: accounts[0], gas: "0xB3E4", gasPrice: "0x4A817C800", value: "0x"})

This doesn't:

token.methods.credit('0xc4beccd2ebdb32203800dfbc60ff0dd7c2762b48', 500000000000000000).send({from: accounts[0], gas: "0xB3E4", gasPrice: "0x4A817C800", value: "0x"})


texts: Is there any way to send a call message, requesting a transaction?

texts:
Example: The human owner of ERC20 wallet (X) owes the human owner of ERC20 wallet (Y) an amount of (T) ERC20.

Is there any function that the owner of Wallet (Y) can send a request message to the owner of Wallet (X) requesting the owed amount?


texts: What is the difference between keys for signing and for encryption in Eth-Lightwallet

texts:
I was exploring this code from the tests in eth-lightwallet:

describe('Asymmetric Encryption', function() {

    it('encrypts and decrypts a string', function (done) {
        var pw = Uint8Array.from(fixtures.valid[0].pwDerivedKey);
        var ks = new keyStore(fixtures.valid[0].mnSeed, pw);
        var hdPath = "m/0'/0'/2'";
        ks.addHdDerivationPath(hdPath, pw, {curve: 'curve25519', purpose: 'asymEncrypt'});
        ks.generateNewEncryptionKeys(pw, 2, hdPath);
        var pubKeys = ks.getPubKeys(hdPath);
        var msg = "Hello World!";
        var encrypted = encryption.asymEncryptString(ks, pw, msg, pubKeys[0], pubKeys[1], hdPath);
        var cleartext = encryption.asymDecryptString(ks, pw, encrypted, pubKeys[1], pubKeys[0], hdPath);
        expect(cleartext).to.equal(msg);
        done();
    });
});

The use of encryption.asymEncryptString() is described as:

encryption.multiEncryptString(keystore, pwDerivedKey, msg, myPubKey, theirPubKeyArray [, hdPathString])

Ignorant of a possible difference between the keys for signing and encryption I tried an Eth address in the theirPubKeyArray Eg.

pubKeys[0] = ["09d5043d675d5ca75ee7bb51691fcc44543faade"];

I got an error in a checkBoxLengths function somewhere reporting that it was a bad public key size.

I noticed the keys generated by generateNewEncryptionKeys() were longer. What is the difference here?


texts: Why are ether delta gas prices so high as of recently?

texts: My question is about why the gas price and gas limit are so high as of lately on ether delta?


texts: Sending ethers to named function with parameters fails

texts:
I am trying to send ethers to a named function with parameters, But for some reason the transaction fails, according to my understanding this has something to do with the type of parameters, because it works when the parameter type is "address" but fails with "string", "bytes32", "uint256". solidity version: pragma solidity ^ 0.4.15;
Please find the code below:

This fails:

struct transact{
    address to;
    address from;
    uint amt;
    uint256 timeStamp ;
}

mapping(string => transact) transactions;

function addTransaction(string _transactionId, uint256 _timestamp, address _to) payable{

    transactions[_transactionId].from = msg.sender;
    transactions[_transactionId].amt = msg.value;
    transactions[_transactionId].to = _to;
    transactions[_transactionId].timeStamp = _timestamp;

}

function getTransactionDetails(string _transactionId) constant returns(address, address, uint, uint256){

    return (transactions[_transactionId].from, transactions[_transactionId].to,
    transactions[_transactionId].amt, transactions[_transactionId].timeStamp);

}

How i call is:

constractInstance.addTransaction("123", 1234, "0x59826af1c1b5beed865a835ea42493d1877fca15",{ from: web3.eth.coinbase, value:web3.toWei(1000, "ether")});

For testing purpose i tried this

This Works

struct transacttest{
    address to;
    address from;
    uint amt;
}

mapping(address => transacttest) transactionstest;

function addTransactiontest(address _to) payable{

    transactionstest[_to].from = msg.sender;
    transactionstest[_to].amt = msg.value;
    transactionstest[_to].to = _to;

}

function getTransactionDetailstest(address _to) constant returns(address, address, uint){

    return (transactionstest[_to].from, transactionstest[_to].to,
    transactionstest[_to].amt);

}


texts:
When I launch mist, it starts up a geth node by default. How do I specify the configurations for this node?

Specifically, I just want to achieve the equivalent of geth --cache=1024 which I can do via a CLI prior to launching the mist GUI.


texts: How to retrieve address of storage bytes arrays longer than 31bytes?

texts:
If I deploy the following contract in Remix the bytes array test get stored at address 0x00 in storage.

contract parseBytes {
  bytes test = "\x20\x00\x10";
  function f() {
    assembly{
        test //should push address of test bytes array and offset to stack
        pop //should pop offset
    }
  }
}

If I extend the bytes array to longer than 31 bytes the storage looks:

0x0000000000000000000000000000000000000000000000000000000000000000: 41
0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563: a020001000100001000e238989d74a050072b08989d74a050040000f0204000000

So it seems that the 32bytes get stored elsewhere (at address 0x290...). How can I retrieve this address using inline assembly? Executing the function above the stack contains the values:

0: 0x2d        //is not the address of the bytes array in storage

1: 0x26121ff0


texts: Is it safe to sign messages with Personal Sign?

texts:
I need to sign a message on behalf of the owner and allow the user to deliver my signed message to the contract. I read the metamask documentation, sample signatures, and many different source code examples.
https://metamask.github.io/metamask-docs/API_Reference/Signing_Data/Personal_Sign

Eth Sign Signatures are not secure. And I don’t need such complex signatures as Sign Typed Data V3. But is it safe to use Personal_Sign? My key can't be stolen? Is it difficult to forge this signature?


texts:
My use-case requires that I feed my contract with a long string (Base64 data), which requires to split it and send it over several transactions so as to not reach gas limit. Then the contract rebuilds the Base64 data by concatenating the string received, like so:

pragma solidity 0.6.8;

contract Concatenation {

    string public base64Data;

    function concat(string memory pieceOfData) external returns (string memory) {
        base64Data = string(abi.encodePacked(base64Data, pieceOfData));
        return base64Data;
    }

}

This snippet is highly inefficient as base64Data is basically overwritten at each iteration, instead of simply being appended each pieceOfData. This creates an exponential gas cost as the written data gets larger and larger (as far as i understand the EVM).

Is there a more gas-efficient solution than the snippet above to concatenate a string?

NB: This data has to be stored in the smart contract state (cannot use Swarm/IPFS)


texts: Sync Chaindata of Geth with Ethereum Wallet / Mist

texts: I have downloaded the blockchain via geth on my mac terminal. When i download the ethereum wallet, I find that it downloads the chain data again. Is there a way to get the ethereum wallet to use the chaindata already downloaded via geth.


texts:
I'm trying to create an initialization script for testrpc that creates specific accounts with specific balances at start up.

testrpc  --debug -account="aa73b5c98e60d589e71ce7cff59c02f82e12c7ce676ee356da8e058a285ccd61,100000"

generates the following

testrpc  --debug --account="aa73b5c98e60d589e71ce7cff59c02f82e12c7ce676ee356da8e058a285ccd61,100000"
/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/solc/soljson.js:1
(function (exports, require, module, __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read(filename,binary){filename=nodePath["normalize"](filename);var ret=nodeFS["readFileS

RangeError: private key length is invalid
    at RangeError (native)
    at Object.exports.privateToPublic (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-util/index.js:356:20)
    at StateManager.createAccount (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/statemanager.js:155:25)
    at Array.map (native)
    at StateManager.initialize (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/statemanager.js:71:33)
    at new GethApiDouble (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/subproviders/geth_api_double.js:21:14)
    at Object.Interface.provider (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/interface.js:148:25)
    at Object.Interface.server (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/interface.js:29:25)
    at Object.TestRPC.server (/usr/local/lib/node_modules/ethereumjs-testrpc/index.js:5:22)
    at Object

The private key I'm using was generated in the previous run of testrpc as a test account:

Available Accounts

  (0) 0x22ddfe3c6439839edf8e2e56126c65c5fc5a2f40 (1)
  0xc1da5556ecfc0ac4168d60bc8c884ae3dd6fba3f (2)
  0xb234a0c1afbd20e1f9a117272136aeaafaccb614 (3)
  0xc8c206e296e92a475ee4c2bf9fb8d00d7ac83876 (4)
  0x8b22109f827a7d6b16b085f9755e23a124a21709 (5)
  0x34cb6cc7cc29f6ce978521ad691716fd7a3809c8 (6)
  0xa3b692025e76530506a232188b6ecd681027585e (7)
  0x9b5a29122e80f8975d50a031b21e88adae489cf4 (8)
  0xa921ef355a7d2729e7674a081aeeceff28419e23 (9)
  0x444a798fad3ef318bfd7cee26c5937298cc2cbec

Private Keys

  (0) aa73b5c98e60d589e71ce7cff59c02f82e12c7ce676ee356da8e058a285ccd61
  (1) 2337bf7968f70bcc7b1c04aba780b6157c3db9c575481c19e90f347f50c5df95
  (2) 8d5cd323b43ee0fe3c3073bbbfa174d682ac8564164b2f253111ee591323a4f4
  (3) fccb97187708748a88c7dd7419c63fa3f5c125826116827f5459c72c2a07cd2a
  (4) 032b517d15b77d0e8d8611beeb3e43021637c37fc4a6efcc40e6fa2fe0e20850
  (5) d5af034aa8990068eee4581012a4010fb78220293464ac3e39ca40f9cb79a873
  (6) 9767f461cc6a1a0688e570846618547de95955d2bfeb37746c6997b7257e156e
  (7) dc6a7f0cd30f86da5e55ca7b62ac1a86f5d8b76a796176152803e0fcbc253900
  (8) 52f3a1fa15405e1d5a68d7774ca45c7a3c7373a66c3c44db94a7f99a22c14d28

I have also tried to use a HEX balance instead of an integer and got the same result.


texts: What will happen if 2 cold storage (Ether) generates a same private key

texts:
I am new to crypto world trying to understand the Ether wallet generation process with the private key. Let us say 2 person A and B are buying a cold storage device "Ledger Nano S" and setting it up for storing the ETH.

There is very low possibility of getting the same private key on both the devices. If that happens, who is the real owner of the ETH in the wallet ?


texts:
How is it possible to either convert uint to int or do simple math comparison operations?

Something like:

uint a;
uint b;
int c;

if (a - b < c) doSomething();

What I'm trying to do is to see if the subtraction of two integers are negative or not. however one of those values comes from msg.value so it should be uint, and I'm not sure if we do uint - uint the result could smaller than 0 to check it on if condition.


texts: Why some transactions with lower gasPrice are proceeded faster?

texts:
I've been observing this chart on ethgasstation.info for some time.

Those values are average from last 1500 blocks. Every time I look at the chart, confirmation time is shorter for gasPrice 1 gWei, but it should be shorter when gasPrice is 2 gWei. What do you think: is there some issue with this chart itself, or is it a rule of thumb for low gasPrice values?


texts: Ethereum fork that implements transaction ordering

texts:
Hyperledger fabric has its consensus that contains

Transactions endorsement
Transactions ordering
Transactions committed to a block

I wonder if there is an Ethereum consensus or fork that would have this ordering feature - that might help around the attack vector that is Transaction-ordering attack


texts:
I am having an issue creating a contract on the Ethereum test net. I am getting the following warning statement:

sol:21:5: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.


texts: send().catch() doesn't give me the error message anymore

texts:
I'm using Truffle/Drizzle/MetaMask and calling methods with send() and using .then() and .catch() and I rely on getting the error message send to .catch() e.g.

contract.methods['hello'](arg).send({
    from: drizzle.web3.eth.accounts.givenProvider.selectedAddress
})
.then(() =>

    // do good stuff

)
.catch((error) => {

    const message = error.message;

    // display a nice message to the user

}

to do things like tell the difference between the user cancelling the transaction and throwing "User denied transaction signature" vs my contract throwing a revert message (and which one) or a nonce mismatch so I can display a more helpful message in the UI.

However, error.message no longer gives me anything, all I get is Internal JSON-RPC error. no matter what the error.

Is this a change in MetaMask or Web3? It was working the last time I worked on my DApp a month ago.

How do I tell the difference between user cancel vs a revert message vs nonce mismatch, and how do I read the revert message thrown by the contract?


texts: Deploy contract as Authority in Parity PoA private chain

texts:
I deployed a Proof of Authority chain with 2 nodes, but when I try to deploy a contract with one authority account, it says that there is unsufficient fund in the account.

I though PoA didn't rely on mining, so how can i "mine" in my authority account in order to get enough funds to deploy my smart contract ?


texts: Using web3 estimateGas API (with infura) always returns the last block's gas limit

texts:
I am entirely unsure what the root cause is, but every time I use web3.eth.estimateGas with my call's parameters, it results in the last blocks gas limit as the result (~8 million). I have even tested with a normal transaction which should result in 21,000 gas, but gives around 8 million. Not sure if a limitation of using infura nodes or a implementation issue.

// Get the gas estimate for the current transaction
window.web3.eth.estimateGas({
  from: transactionData.params[0].from,
  to: transactionData.params[0].to,
  data: transactionData.params[0].data,
  value: transactionData.params[0].value,
  nonce: transactionData.params[0].nonce
}, function(error, result) {
  console.log(result)l
}

Here is more specifically the way I am calling the API. Any suggestions?

UPDATE: I have a workaround, instead of using web3, I directly call Infura's eth_estiamteGas with a https POST.
https://infura.io/docs/ethereum/json-rpc/eth_estimateGas


texts: geth.log is 84.73GB, so that mobile phone complains no disk space left. Would the geth.log be mandatory to generate?


texts: Composition Over Inheritance - Gas Efficiency

texts:
In OOP languages, composition over inheritance is a well-known best practice. Solidity is an OOP language too but there is also the gas efficiency issue.

Question is, in Solidity, how do composition and inheritance compare to each other considering respective gas costs?

P.S. Also asked in SO: https://stackoverflow.com/questions/52515714/composition-over-inheritance-in-solidity-gas-efficiency


texts: How many types of accounts are available in quorum

texts: In Ethereum two types of accounts are there.EOA and contract account.Does quorum run in samy way that means it is similar like ethereum.