texts: Wallet sync restarts from block 0 after closing and launch

texts:
I downloaded the Ethereum-wallet for OSX and started the sync. It took like 10 hours to sync more than 1M blocks.

I closed the wallet and restarted today, but I was surprised to see that the sync is starting from block 0.

Is it normal that the sync restart from 0 after closing the wallet?  If not, any thoughts on why this happened?


texts: Query multiple smart contracts' public data

texts:
I have a smart contract that holds the details of a person. Each new person gets a new smart contract that they 'own'.

I have a regulator/ admin who wants to see the number of such smart contracts existing on the system and see the person who owns it. He will not be able to view any of the private data stored on them (data will be encrypted). Only the owner name (public variable) will be in unencrypted form. Is it possible to write a function that does this? I have considered making a registry that stores the address vs the owner name on a database but am looking for a solution just using smart contracts.

contract People{
    bool public isActive = false;
    uint public objectId;
    string public ownerName;
    string somePrivateData;
    mapping (address => bool) owned;

    function initPeopleContract(string name){
        if (!isActive) {
            isActive = true;
            ownerName = name;
        }
    }

    function getOwnerName() returns (string val) {
        if (!isActive) {
          val = ownerName;
        }else {
          val = "Account Deactivated";
        }
    }

    function getPrivateData() returns (string data) {
        if (msg.sender == address){
          // Send the data back
        } else {
          // Reject due to un-authorized request
        }
    }
}

The last function is incomplete, I will add parts that check whether the person who request the transaction is really the owner of the smart contract or not. The ownerName is a public variable that the admin should be able to query and view.

I am using web3.js , browser solidity to compile abi code and a private block chain run using geth console commands.


texts: Does everyone who invested in Pre-ICO get the same rate, once the ICO is over?

texts:
I would like to know if all the people who invested in a coin (any coin) during Pre-ICO are all buying at the same rate or at the same price.
For instance, during Pre-ICO, A buys today and B buys a week after, are both A and B investing at the same rate? How is Pre-ICO investments calculated since most coins have no steady chart before ICO?
Thanks


texts: What are some stablecoin projects built on Ethereum and how do they distinct between each other?


texts: Can I restrict new users to create a password and then access their data next time by only passing the password and getting validated? (Solidity)

texts: I am trying to build a Dapp for healthcare where I must be able to allow patients(users) to enter their details after creating (say an account) by a password and next time they are able to view their data by entering the password they created.


texts: How to facilitate search and look-up from outside?

texts: Given a master contract that continually generate child contracts, how to facilitate outsider to read some data located in the child contracts. In other words, how to publish the addresses of the Childs contracts?


texts: How to reach to one chain when hard fork is performed?

texts:
Assume that reward policy of Ethereum is changed from 3eth to 1eth.

Hard fork is ongoing but, there are miners who don't consider updating their software.

what happens?

The miner who did update will record reward of coinbase transaction as 1eth, but the miner who didn't update will record reward of coinbase transaction as 3eth.

Assume that number of miners is 10 in the world. three people did update and others didn't. three people know the reward is 3eth but seven people know the reward is 7eth. it result in remains inconsistent between two groups.

My questions :

The senario explained above cannot do hard fork. blockchain will be got screwed if the blockchain initiate hard fork. so how to successfully achieve chain consistency?

Sorry for my English.


texts: How to call mint function using Nethereum

texts:
I am getting the error calling the mint function on a contract.
Error:  Nethereum.JsonRpc.Client.RpcResponseException: execution reverted

I used ERC721PresetMinterPauserAutoId from OpenZeppelin for the erc721 contract.
Then used VsCode Solidity extension to generate the code. The generated files are: ERC721PresetMinterPauserAutoIdService
When I tested the code using truffle in the development environment and in ropsten it worked.
When I try to call with the Nethereum code below, I get the execution reverted.
var account = new Account(privateKey);
var web3 = new Web3(account, $"https://ropsten.infura.io/v3/{projectId}");
ERC721PresetMinterPauserAutoIdService srv = new ERC721PresetMinterPauserAutoIdService(web3, contractAddress);
MintFunction mint = new MintFunction { To = toAddress };
var result = await srv.MintRequestAndWaitForReceiptAsync(mint, null);
Console.WriteLine($"transaction index: {result.TransactionIndex}");

Any help woudld be appreciated.


texts: Has anyone found a fix for "ParsedContract.sol:3:1: ParserError: Source file requires different compiler version"?

texts:
Following the truffle pet shop tutorial and ran into this error when running truffle migrate:

ParsedContract.sol:3:1: ParserError: Source file requires different compiler version (current compiler is 0.5.2+commit.1df8f40c.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
contract Election {
^------^
Compilation failed. See above.
Truffle v5.0.0 (core: 5.0.0)
Node v11.2.0

when running truffle version I get:

Truffle v5.0.0 (core: 5.0.0)
Solidity v0.5.0 (solc-js)
Node v11.2.0

and in my contracts Im using:

pragma solidity ^0.4.24

Has anyone ran into this issue? Any help getting past this would be appreciated.


texts: How to tell how many graphics cards a mother board can concurrently use (can each pcie 3.0 slot be used?)

texts:
looking at motherboards on newegg I am filtering based on ones that have 4 or 5 pcie 3.0 slots. my 2nd criteria will be the most efficient cpu for less power consumption.

My question is if you are building a rig how can you tell if the motherboard will actually accept a graphics card in every PCIe 3.0 slot. I plan to use risers, but I have read online that just because the motherboard has 5 pcie 3.0 slots doesnt mean it will actually be able to handle 5 graphics cards for mining. Is  there any way to tell? I know this mining scenario isnt very mainstream so reviews rarely mention this. (All the Asrock mining boards seem to be sold out and those are the only ones i have seen that confirm the ability to accept a graphics card in every PCIe slot).

Sub question, can i plug a pcie 3.0 card into a pcie 2.0 slot? The rx 480 says its pcie 3.0, does that mean I cant plug it into a pcie 2.0 slot?

What's the best Hardware for Mining Ether?

I noticed that thread and was hoping to ask a more detailed question in regards to determining if a specific motherboard is appropriate or not.


texts: How to debug mappings of structs in truffle tests

texts:
This is my test file:

pragma solidity ^0.4.24;

import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/Salaries.sol";

contract TestSalaries {

    function testEmployeeInsertion() public {
        Salaries salaries = Salaries(DeployedAddresses.Salaries());
        address addr = address(0);
        salaries.addEmployee(address(0), "Alicia Drake", "Lead Engineer");
        Assert.equal(salaries.employees(addr).name, "Alicia Drake");
    }
}

And the definitions in Salaries.sol:

struct Employee {
    string name;
    string role;
}
mapping (address => Employee) public employees;

How can I write tests for verifying the employee's name and role? Currently, I'm getting the following error:

TypeError: Indexed expression has to be a type, mapping or array (is tuple(string memory,string memory))
        Assert.equal(salaries.employees(addr)[0], "Alicia Drake");

Similarly, is there a way to log the variables in the console while running the tests?

Using truffle 4.1.14.


texts: Ethereum Name Service (ENS) is case-sensitive?

texts:
Are the ENS addresses case-sensitive?

Making different example.eth from ExAmple.ETH?

If I'm going to bid on a name I must pay attention on that?


texts: Send 1% of Ethereum sold by one account to another

texts:
I made an arrangement with a friend in which he agreed to give me 1% of all the Ethereum that he sells at the time of sale. So he owns 100 Ether today; in 1 year he goes to sell 10 Ether, I would be sent 0.1 Ether from his account at that moment.

How would I go about capturing this in an Ethereum contract? I'm unclear about:

How to "reach into" his account to get 1% of his sale; I'm guessing that he'd need to place 1% of his Ethereum into some "escrow" account up-front?
How to "trigger" an Ethereum contract on the basis of some other event on the blockchain (in particular, the sending of Ether from some particular address).

I'm totally new to Ethereum, so pardon me if I'm getting some of the wording/concepts wrong.


texts: json rpc hex string weird padding/encoding

texts:
When sending eth_call to get erc20 token WETH name and symbol I get hex response padded with bunch of zeros and a mysterious digit '2'.

for symbol I get response:

"0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000045745544800000000000000000000000000000000000000000000000000000000"

for name I get response:

0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d5772617070656420457468657200000000000000000000000000000000000000"

When I convert responses to utf8 string I get:

��������������������������������WETH
�������������������������������Wrapped Ether

The routine to decode hex strings from ethereum.js unpads only up to first '2' that it finds. Although padding with zeros continues until actual chars begin.

Why such a 'weird' encoding of response and how to properly decode it?


texts: EIP20 Token creation error in REMIX :Error encoding arguments: Error: invalid address

texts: Im new to creating tokens and I'm having a problem with this code of EIP20 :


texts: Invalid parameters: must provide an Ethereum address. Code -32602

texts:
Here is the transaction I am trying to send using web3.eth.sendTransaction:
{
   data: "0x11a861a700...."
   from: "0x8ccb1711ea5562596f146608fdcf27ccf0d5429c"
   gas: "0x6b540"
   gasPrice: "0xaf16b1bb3"
   nonce: "0x0"
   to: "0x7113dd99c79aff93d54cfa4b2885576535a132de"
   value: "0x38d7ea4c68000"
}

It keeps getting back with the following message:
MetaMask - RPC Error: Invalid parameters: must provide an Ethereum address.
Is there some kind of other form this TX should be fed to web3?
edit. This transaction was generated by https://1inch.exchange/#/api using the following GET request:
https://api.1inch.exchange/v1.1/swap?fromTokenSymbol=ETH&toTokenSymbol=BAT&amount=2000000000000000&fromAddress=0x8ccb1711ea5562596f146608fdcf27ccf0d5ZYZc&slippage=1&disableEstimate=true

edit. XYZ addresses are just placeholders.


texts: Error when checking the value in a mapping

texts:
I am trying to keep track of the number of bidders in my contract.

 function bid() public payable an_ongoing_auction returns (bool){
    uint oldval = bids[msg.sender];
    require(msg.value+oldval > highestBid,"You can't bid, Make a higher Bid");
    highestBidder = msg.sender;
    highestBid = msg.value+oldval;
    if(oldval==0)
        bidders.push(msg.sender);
    bids[msg.sender] +=msg.value;
    emit BidEvent(highestBidder,  highestBid);
    return true;
}

If I remove the if statement the code run fine, but I want to only push the my bidders array when there is a new bidder. I am using remix and get the error:

transact to MyAuction.bid errored: VM error: revert.
revert  The transaction has been reverted to the initial state.
Note: The constructor should be payable if you send value.  Debug the
transaction to get more information.

I am new to solidity so sorry if this is an easy answer, but I couldn't find anything on it.


texts: How to call setter method of smart contract with web3 1.0.0

texts:
I don't know why but i'm not able to perform transaction with this code.
please help me out i'm stuck. i just have to call setter method of my contract with some arguments.

router.post("/set", async function (request, response) {

let fromAddress = request.body.from_address;
let privateKey = request.body.from_private_key;
let contractAddress = request.body.contract_address;
let caseId = request.body.case_id;
let userIdentityAddress = request.body.user_identity_address;
let complaintType = request.body.complaint_type;
let complaintNature = request.body.complaint_nature;
let complaintDescription = request.body.complaint_description;
let document = request.body.document;

console.log(fromAddress)
// const sleep = (milliseconds) => {
//     return new Promise(resolve => setTimeout(resolve, milliseconds))
// }

const contract = await new web3.eth.Contract((abi), contractAddress);
let count = web3.eth.getTransactionCount(fromAddress);
web3.eth.defaultAccount = fromAddress;

const tx_builder = contract.methods.createCase(
    caseId,
    userIdentityAddress,
    complaintType,
    complaintNature,
    complaintDescription,
    document)

let encoded_tx = tx_builder.encodeABI();

let gasPrice = await web3.eth.getGasPrice();
let gasLimit = 500000;
let transactionObject = {
    "nonce": web3.utils.toHex(count),
    "from": fromAddress,
    "gasPrice": web3.utils.toHex(gasPrice),
    "gasLimit": web3.utils.toHex(gasLimit),
    "to": contractAddress,
    "data": encoded_tx,
    "chainId": 0x03
};

web3.eth.accounts.signTransaction(transactionObject, privateKey, function (error, signedTx) {
    if (error) {
        console.log('thiss', error);
        // handle error
    } else {
        web3.eth.sendSignedTransaction(signedTx.rawTransaction)
            .on('receipt', function (receipt) {
                console.log('heloo', receipt)
            });
    }
})

Error Response:
  { messageHash: '0x7c02b35df7d5c6eea7dba25fe38fe29b224e4e38eff2dda76ca70629ac330f44',
  v: '0x2a',
  r: '0x5675ff3d56b6b57c18dcc35fc3396a12bb1c3bb338537047ff10bea687ae9e21',
  s: '0xb38d8a3b19ba34aea031b9e286fa0e4733dfb6640313d594321d626f5c87110',

If you see here 's' is missing one hex character

(node:26007) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Returned error: invalid argument 0: json: cannot unmarshal hex string of odd length into Go value of type hexutil.Bytes
(node:26007) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

After logging transactionObject and signedTx


texts: Deploying multiple contracts: contract not deployed to detected network

texts:
I'm having a problem deploying multiple contracts. The first address gets written in contract1.json but contract2.json isn't showing an address. My second contract constructor function takes 3 args: bool, uint, address. In web3 I get the following error:

Contract2 has not been deployed to detected network (network/artifact mismatch)

var Contract1 = artifacts.require("./Contract1.sol");
var Contract2 = artifacts.require("./Contract2.sol");

module.exports = function(deployer) {
   deployer.deploy(Contract1).then(function(instance){
        deployer.deploy(Contract2, true, 20000, Contract1.address);
     })
    }

This is my truffle:

Using network 'develop'.

Running migration: 1_initial_migration.js
  Replacing Migrations...
  ... 0xf04f5da0e200f40dc8b96b505242fda61380088e89f5fd878d6f65534409109b
  Migrations: 0x8cdaf0cd259887258bc13a92c0a6da92698644c0
Saving successful migration to network...
  ... 0xd7bc86d31bee32fa3988f1c1eabce403a1b5d570340a3a9cdba53a472ee8c956
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Replacing Contract1...
  ... 0x8cf05bf0dbaf4917f4554272b08a36e36c05923ddb1bd96c863b4633d60819cf
  Contract1: 0x345ca3e014aaf5dca488057592ee47305d9b3e10
Saving successful migration to network...
  Deploying Contract2...
  ... 0xf36163615f41ef7ed8f4a8f192149a0bf633fe1a2398ce001bf44c43dc7bdda0
Saving artifacts...
  ... 0x1b968d4d74677f26876edda4aed7026782547dd651b0db5791eb220d4caa030b
Contract2: 0x8f0483125fcb9aaaefa9209d8e9d7b9c8b9fb90f

I can interact with the first contract using my dapp. If I want to interact with my second contract I get the error.


texts: do the authorized nodes check the public key or the signature of each transaction in the beginning and how long it would take as the PoA is lightweight  consensus


texts: Is it possible to create an address using ethereumjs without a Geth node?

texts:
I am working on a iOS & Android-App which is interacting with the blockchain via a Geth node behind an API. Is it possible to do the following:
1. generate an address using a package like EthereumJS
2. Sign transactions with it
3. Accept those transactions with the Geth node?

Or is it only possible to generate addresses from a Geth-Node?
Thank you!


texts:
I am new to solidity :) and try to encapsulate array of contracts in one contract.
Something like this:
contract Item{
     uint public blabla1;
     uint public blabla2;
}

contract Collection{
    Item[]public items;
}

How can I do it? Any workarounds?


texts:
Is there any way to assess the number of blocks being mined in Ethereum by ASICs versus the number of blocks being mined by GPUs percentage-wise?
Karim Helmy designed away to estimate the type of ASIC rig being used to mine Bitcoin based on analysis of the nonce. Is there something similar in the Ethereum network?


texts: How to get decrypted transaction data in quorum?

texts:
On Quorum_Node1 I am sending a transaction with privateFor: parameter as follows:

eth.sendTransaction({from: eth.accounts[0], to: "0xca84356...9a3d0ccf92b8e",
data: web3.toHex('sample message for node 2'),privateFor:
['QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=']})

Where QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc= is a public key of Transaction Manager on Quorum Node2

When I try to get the transaction data on Quorum Node2 via:

eth.getTransaction("0x26a550c39b816...97c6f6eb35c3953e53b7")

I am getting an encrypted payload. Ideally, I should receive hex representation of the data sent in the original transaction.

Is this possible in Quorum or it works just with contracts?


texts: Does truffle test mimic the exact network state of an actual migration?

texts:
I've defined a truffle migration step as follows:

Deploy my 'main' smart contract, nothing out of the ordinary:

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

   module.exports = async (deployer) => {

     await deployer.deploy(UniversityVoting);

};

I then deploy an ERC20 token contract, called VotingToken. As you can see, in module.exports, I get an instance of UniversityVoting which I deployed in step 1, so I can then pass the address of the newly deployed VotingToken to it:

var VotingToken = artifacts.require('./VotingToken.sol');
var UniversityVoting = artifacts.require('./UniversityVoting.sol');

module.exports = async (deployer) => {

    UniversityVotingInstance = await UniversityVoting.deployed();

    await deployer.deploy(VotingToken, UniversityVotingInstance.address);

    await UniversityVotingInstance.setVotingTokenAddress(VotingToken.address);

};

This works fine using truffle migrate
and I can indeed see the correct VotingToken address in Ganache:

But in a test written in JavaScript that I execute using truffle test, where I create a new instance of UniversityVotingand call a getter method that returns deployedVotingToken it returns a 0 address. Why would that happen in a truffle test? I thought it was supposed to run your migration files?

describe("Deploy and use the child institution contract", function() {
  before(async function() {

    universityVoting = await UniversityVoting.new(
      {
      from: developerAccount
    });

...

// In an 'it' block

const originalToken = await universityVoting.getVotingTokenAddress();

originalToken.should.equal("[exampleAddress]");  // Here it says that AssertionError: expected '0x0000000000000000000000000000000000000000' to equal '0x34344343434'


texts:
I am new to programming and trying to access a struct located in another smart contract but am receiving the following error.

"TypeError: Member "Address" not found or not visible after
argument-dependent lookup in
tuple(address,int16,int8,uint256,bool,int256,address). -->
Auction.sol:45:23: | 45 | if(bid == r.users(i).Address) x = true;"

Is it possible to access structs in mappings of different contracts?
My code is as follows:
pragma solidity ^0.8.3;

contract Registry {

    mapping(int => User) public users;
    int8 public userCount = 0;

    struct User {
        address Address;
        int16 Longitude;
        int8 Latitude;
        uint Transformer_ID;
        bool Is_Prosumer;
        int Peak_Power;
        address Smart_Meter;
    }

    function addUser(int16 _longitude, int8 _latitude, uint  _transformerID, bool  _isProsumer, int _peakPower, address _smartMeter) public {
        users[userCount] = User(msg.sender, _longitude, _latitude, _transformerID, _isProsumer, _peakPower, _smartMeter);
        userCount ++;
    }
}

contract Auction {

    Registry r;
    address registryAddr;
    function RegistryRead(address addr) public {
        registryAddr = addr;
        r = Registry(r);
    }

    function verify(address addr, address bid) public returns (bool) {
        int i; bool x = false;

        int8 max = r.userCount();

        for(i = 0; i == max; i ++)
            if(bid == r.users(i).Address) x = true;

        return x;
    }

}


texts: Storing a particular ERC20 balance value of a smart contract in a global or local variable

texts:
how does one go about storing the ERC20 balance value of a contract in a local variable, with the ultimate purpose of using this value for later calculations within the same function?

uint256 varName = ERC20Object.balanceOf(this);

if done locally within a function it will always return 0 regardless of the ERC20Object balance being e.g. 1k-100mil. How to fix this and have varName show the correct number instead of 0?


texts: Why my "only view wallet" address is different from "my wallet address"? (I can't see my funds)

texts:
I am an ethereum investor and user since 3 years ago.  In the past I opened / created a wallet in Myetherwallet (MEW) (address: 0x....ad19), as everyone recommended me because of the security. I followed the steps to open the wallet with no problem but I only received a PRIVATE KEY and a .JSON file when I did it,  (no security factor else, such as nemoniac phrase, QR code,  seed phrase, or anything). In the begining I created a username and a password that I used to access  to my MEW wallet each time since then.
After that,  I deposited some ETH and many other ERC20 tokens that I bought in some exchanges, in that new wallet and everything was fine for almost 2 years, and all my funds kept safe without a problem, even I could check my  funds everyday in MEW Google Chrome Extension (GCE), until three or four months ago when I realized that MEW team had update the platform and the website as the GCE, and when I tried to check my funds as everyday in the past, I couldn't view my funds anymore because the system asked me to update to the newest MEW version which I did but when I tried to recover my last MEW wallet with all my funds (0x...ad19) in the new MEW site and in the new GCE, with my username,  my PW,  my Private key,  and my .JSON file, the system recovered my old wallet (0x...ad19) but automatically generated me a new ERC20 address (0x....f455)  with no coins and tokens at all. The curious thing is that even this problem, my original MEW wallet address (0x...ad19) show me all my funds when I search it in Etherscan.  Beside this, I can see in GCE that "my only view wallet" address (0x...ad19) is different from "my wallet" address (0x...f455). I can see my funds in the first one but I can't withdraw it,  send it,  or anything at all.
I hope I explained myself clearly.
With this info,  Can anyone help me with this issue? Have anyone had this problem in the past? Any solution? Or do I accept the loss only?
HEEELP!


texts: analyzing transaction cost for a smart contract

texts:
Given a smart contract, How do I figure out the total amount of gas used?
Say for example a smart contract which has a parameterized constructor which stores 5 variables which are address type variables, passed in the parameter of a function. What would be the amount of gas this function uses?

also, whoever uses the smart contract can give their choice of gas cost?


texts: How to store data in arrays in smart contracts

texts:
I am learning solidity and my test project is a simple ticket system.

Basically, users will use the smart contract to buy movie tickets. The contract will issue a ticket and store the user's address and the number of tickets purchased.

I want to store this in a type of array like so:

tickets[ShowIdentity][] = [
    userAddress,
    totalTickets,
    pricePaid
]

I have read that mappings are the best way to store data however I am unsure how to go about using it.

Any advice and/or some sample code would be greatly appreciated.


texts: Why does a mapping update itself when I am not doing anything?

texts:
The title is a little bit vague but I've seen this contract and tried it on remix:

pragma solidity ^0.4.24;

contract Tester {

  struct Account {
    uint256 balance;
  }

  mapping (address => Account) public accounts;

  function addBalance() public payable {
    Account storage a = accounts[msg.sender];
    a.balance = a.balance + msg.value;

  }

}

What happens is the following:
1. I check the value in the mapping and it's 0
2. I execute the addBalance function sending 10 wei
3. I check the value in the mapping and I see it's 10

How is that possible ? I am not updating the mapping.


texts: Orders Facilitator Contract has not been deployed to detected network

texts:
I'm trying to deploy a simple contract to truffle.   This is very confusing now because truffle has it's own network built into it, yet the tutorial I'm following uses test-rpc.  I've looked at a few other questions about this but none seem to address my specific issue.

I'm running the command:

test-rpc --network-id 1337

Inside of my project I've configured my truffle.js like so:

module.exports = {
    networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "1337"
    }
  }
};

Then I ran:

truffle compile
truffle migrate

truffle console

I check to verify my contract has been deployed in the console by running:

OrdersFacilitator.network_id

this returns 1337 yet when I run:

var facilitator;
OrdersFacilitator.deployed().then(x => facilitator = x);

I receive an error:

  Error: OrdersFacilitator has not been deployed to detected network (network/artifact mismatch)

The weird thing is that when I run OrdersFacilitator.network_id it shows the proper networkId.   How can I fix this issue?


texts: Migrating Ethereum development from Windows to Ubuntu

texts:
I recently had Ethereum on Windows (Ethereum Wallet) and Mix. Later I copied the whole ethereum folder on Windows to a cold storage and installed Ubuntu on the machine.

My question is how do I import those windows ethereum files?


texts: What happens if already processed transaction is submitted to the network again?

texts:
I have a script that sends transactions automatically using JSON RPC API call eth_sendRawTransaction to a node that has RPC enabled.

My question is, what is going to happen if I send these transactions (there may be lots of them, btw) multiple times after they have been already processed?

Lets say, my script has a bug, or the database where I store the sent status of the transaction is deleted, and somehow I resubmit lots of (already processed and stored on the blockchain) raw transactions again? I am basically interested in knowing if I am going to lose money for the second time I submit these transactions? Can miners process it and take the fee, while reporting error?

The logic suggests it shouldn't cost me to submit transactions multiple times because the nonce and transaction hash are unique values, but I want to be sure about it. Also, if resubmitting already processed transactions doesn't cost money, could this be a potential DDoS attack for Ethereum's Main Net? Like, resubmit all the transactions the blockchain already has processed?


texts:
I studied The DAO attack.
Ethereum's reentrancy attack is still work.
but ethereum network also still work( Sure, compiler says "warning" )

How do you believe your contract will be safe?
How ethereum patch this bug?

and How can send ether to anyone without calling fallback function?
this is cause of dao attack

Have ethereum got good idea?

i want you to let me know please.


texts: VM transaction failed reverting the transaction

texts:
Solidity smart contract code is:
function recharge() public payable {
    address payable _wallet=address(this);
    _wallet.transfer(msg.value);
    }

javascript code is:
this.state.contract.methods.recharge().send({from:this.state.owner,value: Web3.utils.toWei(this.state.Recharge, 'ether')})

*contract and owner are stored in a state variable,
but this gives an error
Err0r:VM Exception while processing transaction: revert


texts: ÐΞVp2p / DApps - why is it in "Ð" not "D"? Any special significance of using Ð?

texts: ÐΞVp2p / DApps - why is it in "Ð" not "D"? Any special significance with using Ð instead of the normal D?


texts: Is there an API or library available to integrate an ERC20 compatible wallet into my android app?

texts: If the android app being developed is going to display balances and allow sending and receiving of ERC20 tokens, is there an API or library that people would recommend for this functionality?


texts:
I'm very confused on the concept of gas.

From what I understand, gas is a unit of ethereum, that measures the cost of a transaction. I'm not sure why we call it gas and separate it from ethereum. I read it measures the "technical cost" not "market cost" which makes no sense to me on how.

On average, it takes me $0.10 to send a transaction. So, does this mean when you run out of gas you have less than $0.10 cents of ethereum?


texts: Why local storage vairable not being assigned to storage variable?

texts:
from solidity documentation

Assignments from storage to a local storage variable also only assign a reference.

In this contract, when I  am  intialising x in the function, it defaults to a data location in storage,
so it must reference the data.

why deleting x is not deleting the data?

pragma solidity >=0.4.0 <0.7.0;

contract DeleteExample {
    uint data;
    uint[] dataArray;

    function f() public {
        uint x = data;
        delete x; // sets x to 0, does not affect data
        delete data; // sets data to 0, does not affect x
        uint[] storage y = dataArray;
        delete dataArray; // this sets dataArray.length to zero, but as uint[] is a complex object, also
        // y is affected which is an alias to the storage object
        // On the other hand: "delete y" is not valid, as assignments to local variables
        // referencing storage objects can only be made from existing storage objects.
        assert(y.length == 0);
    }
}

but when we initialized y with storage, it clearly referenced to the original dataarray.
I was under the impression that local variables will always be stored on in-memory until storage is defined explicitly. am I wrong?


texts: How to copy a file to swarm file system (fuse aka swarmfs)?

texts:
I have mounted a swarm file system (fuse aka swarmfs). It shows the previously uploaded file (using 'swarm up file1.txt' command) in it.

However, I cannot copy any file inside it. It is throwing permission related error. I am using linux 'cp file.txt swarmFs/.' command for copying inside this directory. Any idea what am I doing wrong?


texts: Scan Ethereum transactions for known addresses over JSON-RPC

texts:
I want to scan all Ethereum transactions over JSON-RPC API and build a balance tree and transaction map for the address list I know.

What are the most efficient calls to do this? Is there anything more performant than getBlock() followed by getTransaction() for each transaction? Is there way to filter transactions, so that I would only list transactions concerning my addresses over JSON-RPC?


texts: Truffle - a proper way to execute a chunk of code

texts:
Let's say I have a complex operation to execute, for example deploying 6 contracts and calling functions to each one, passing addreses to few of them and executing some extra more functions. I can, of course, call each function manually to pass address and so on, but it takes time and might cause a mistake. So the best way, in theory, would be to have a chunk of code ready to go and executing it once and automatically do the operation.

It would be pretty simple to do it using migration or test, but somebody told me before:

  No, this is not a good use of migrations. Migrations are about
  deploying the system to the network and one-time initialization steps

Adding a builder contract is impossible, because holding few contracts exceeds ethereum limits.

So should I use the Test feature for executing chunks of complex code of my contracts' environment? Even on the mainnet?


texts: RPC connection to private net using MetaMask works, but using geth, mist or solidity browser doesn´t

texts:
I am trying to create a private network consotium in Azure by following this tutorial:

https://github.com/Azure/azure-quickstart-templates/tree/master/ethereum-consortium-blockchain-network

Problem 1 - solidity can´t connect to the private network

Connecting to the network using MetaMask works fine, so I can create accounts and transfer balance from one account to the other. However,
I can´t connect to my network using solidity browser (so I can´t deploy contracts) because of the https->http issue. Running solidity from local host also does not work. It says that the accounts are locked. The goal here is to easily deploy my own contracts to this private network.

Problem 2 - connecting from geth or Mist from localhost doesn´t work

Since solidity browser din´t work, I tried another ways to connect to the network and deploy my contracts. Using Mist the problem is:

method personal_newAccount does not exist/is not available

other threads tell me to start get with  --rpcapi="db,eth,net,web3,personal,web3"
but why does it work with MetaMask then?


texts: Why use filters - eth_getLogs vs eth_newFilter

texts:
It seems to me eth_getLogs is much simpler than eth_newFilter + eth_getFilterLogs.

eth_getLogs has no need for installation, got same parameters, catches events retrospectively. What are use cases of filters at all?

As in my previous question:

from ethjsonrpc import EthJsonRpc
c = EthJsonRpc('127.0.0.1', 8545)
ADDRESS = "0xdb1154368ba2645e6c090f3d1f3ddd5c8c1f8008"
params = {
        "fromBlock": "0x01",
        "address": ADDRESS
    }
before = c.eth_newFilter(params)
for i in range(100):
    tx = c.call_with_transaction(c.eth_coinbase(), ADDRESS, 'setValue(uint32)', [i])
    receipt = c.eth_getTransactionReceipt(tx)
after = c.eth_newFilter(params)

print len(c.eth_getFilterLogs(before)) // 100
print len(c.eth_getFilterLogs(after)) // 0
print len(c.eth_getLogs(params)) // 100


texts:
When implementing the ERC721 contract standard, how strictly does one have to stick to the naming conventions of the method signatures - as spelled out by the standard?
Take for example the ownerOf function. The standard spells it out as follows:
function ownerOf(uint256 _tokenId) external view returns (address);

But what happens if I change the argument names when I implement this function in my contract?
For example:
function ownerOf(uint256 _creatureID) external view returns (addressOfOwner);

So instead of _tokenId I have _creatureID and instead of address I have addressOfOwner?
Does that negate the conformity? Will other platforms not be able to recognize and work with my contract because I made these changes? Or is it only the function's actual name - ownerOf - that matters?


texts: what does `deploy.link` exactly do in `truffle`

texts:
Please explain use cases for deploy.link() function in migrations in truffle framework.
How would you use it and for what.


texts:
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
    _transfer(sender, recipient, amount);
    _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
    return true;
}

Transfer happens before approve. Or does the method fail and everything reverts back if anything in the method fails?


texts: Unable to deploy contract using truffle-contract?

texts:
I'm trying to deploy a new contract via truffle-contract but for some reason it keeps giving me a Error: Invalid JSON RPC response: ""

import Web3 from 'web3'
import contract from 'truffle-contract'

import MyContract from '../build/MyContract.json'

const Contract = contract(MyContract)
const web3 = new Web3(new Web3.providers.HttpProvider('https://ropsten.infura.io/...'))

MyContract.defaults({
  from: 0x...,
  gasPrice: '21000000000',
  gas: 4712388
})

MyContract.setProvider(web3.currentProvider)

async function deployContract() {
  let contractInstance = await MyContract.new()
  console.log(contractInstance.address)
}

deployContract()


texts: Contract creating another contract using Web3 getting out of gas error despite gas value being large (e.g. 50,000,000)

texts:
I wrote a contract A that creates a new contract B and returns the address of the new contract B that's been created.  When I tested this on solidity browser it seems to work well, but when I tried to run the create method using web3, I keep getting this error:

        throw errors.InvalidResponse(result);
    ^
Error: VM Exception while processing transaction: out of gas

Here's my contract code:

pragma solidity ^0.4.2;
contract B {
   int public id;
   function B(int _id) {
     id = _id;
   }
}

contract A {
   address Baddress;
   function createB(int _id) returns (address) {
     Baddress = new B(_id);
     return Baddress;
   }
}

Here's my Javascript code that attempts to run A's createB method:

web3.eth.defaultAccount = web3.eth.coinbase;
var Acontract = web3.eth.contract([{"constant":false,"inputs":[],"name":"getdum","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"num","type":"int256"}],"name":"create","outputs":[],"payable":false,"type":"function"}]);

var A = Acontract.new({from: web3.eth.accounts[0],
data: '{{compiled byte code}}',
gas: '47000000'}, function (e, contract){
   console.log(e, contract);
   if (typeof contract.address !== 'undefined') {
     console.log('Contract mined! address: ' + contract.address);
     contract.createB(5000).then(console.log); // This line throws the error
   }
})

I've read many other related posts and could only find answers that suggest to use more gas, but no matter how much gas I sent with the transaction, it would throw the same error.  You can see I'm using a really large value for gas in the code. Can anyone help me identify what I'm doing wrong? I'm using solc Version: 0.4.9+commit.364da425.Darwin.appleclang, EthereumJS TestRPC v3.0.3, and node v6.4.0.


texts: How to get contract's ether balance at hardhat / waffle

texts:
I writing hardhat/ethers/waffle unit tests for my contract and need to know Ether balance of my contract.
Chai matcher changeEtherBalance needs Signer object to check balance, but I have address of my contract only.
I know, what ethers.js has provider object with getBalance(address) method, so I have installed nomiclabs-hardhat-ethers plugin and can call
ethers.provider.getBalance(address)
It works well for addresses from signers ethers.getSigners() but returns 0 for mycontract.address.
How I can know my contract Ethereum balance?
Please advice.


texts:
I participated in two ICOs. It asked for an Ethereum address, I gave it the address of my Binance Acct.  The Binance account did not save the tokens or the ERC20 deposits.  However, when I go to Etherscan, it shows the value, the deposits, and tokens, almost $600.

Is there anyway to transfer or recover these?


texts: Why I can not use ./geth --testnet --fast --cache=1024 --jitvm for geth 1.4.7?

texts: I tried two times. Each time block count is for mainnet and there is no any chaindata for testnet


texts: Why eth nodes found in ethernodes drop so much?

texts: I have just visited ethernodes (a website that records eth nodes)and found the nodes it found has drop to 3990 while this number is 10K about 2months ago.What happen?Is it true that Ethereum nodes are down a lot or just because  his detection method is  being blocked????


texts: How to create and sign a transaction locally using Go

texts: Geth's code can be used as a library. Are there any code examples that use Geth to sign a transaction locally? I then want to POST the resulting string using eth_sendRawTransaction.


texts: How to Manage Bulk of transaction through web3.js?

texts:
I have following code to send a transaction:
const account = web3.eth.accounts.privateKeyToAccount(process.env.PRIVATE_KEY_1)
const transaction = contract.methods.submitHash(docHash);
const options  = {
    to      : transaction._parent._address,
    data    : transaction.encodeABI(),
    gas     : await transaction.estimateGas({from: account.address}),
    gasPrice: web3.utils.toHex(web3.utils.toWei('20', 'gwei')),
};

I want to be able to call web3.eth.sendSignedTransaction more than 50 times with different messages. I want to have a transaction for each message stored so that I can have tx hash.  Txhash is required so that we can easily view that the hash of a document is stored in the ethereum blockchain. The problem when I use a for loop is the nonce doesn't seem to increase.
I get: replacement transaction underpriced
Also I will be having a less gas fee for each transactions to send bulk of transaction so, does that mean if one transaction takes a long time to get mined the following transactions won't begin to be broadcasted at all? Will batch ethereum transaction do the trick or will I have to wait for a very long time as the transaction fee provided will be low and needs in average 3 hours for each transaction to get mined?


texts: Unable to connect to metamask using web3

texts: I have tried everything but just can't get the web3.currentProvider to work. I have metamask installed and working and somehow want to connect the website on the test network. Has there been some recent update which is not reflected in the documentation?


texts: What does it mean that the next DAG is in X days?

texts: Before you jump all over this a duplicate question. I did read things related to DAG like here: What actually is a DAG? But that doesn't answer my question, what does it mean when my mining pool website says that the next DAG is in X (4 in my case) days? How does that affect me as a miner?


texts: I believe i correctly backed up the keystore files, however, once I copied the keystore file back into my new ethereum directory, it doesnt show my funds in my wallet. Do i need to enter my password somewhere? Or is it because the wallet is not synchronised yet? thank you


texts: How do I get the address from a signature?

texts: As stated in the question, I have the v, r and s values of a signature given and am trying to find the belonging address. All questions similar to this solved it by either using a solidity smart contract or web.js. Is there a way to do this without using these two resources, and preferably, any other external resources?


texts: I am searching for a way to get credentials for ethstats on the main-nets. I found some references that you could get them on a skype-channel. Would love to not use skype - is there another way?


texts: Maximum gas consumption of calling a contract method

texts:
I want to evaluate the maximum gas consumption (minimum safe gas limit that will not fail) that calling a specific contract method would consume given that I have the contract source code / byte code.

I remember a few months ago seeing a website where you can enter the solidity code and it calculates how much gas this code would consume, but I can't find this website anywhere.

Just to clarify - I know there's a method in the API that can estimate gas consumption of transaction which is only an estimate since it's based on the variables that can change (such as block number etc), but I'm talking about maximum gas consumption given the contract source code / byte code is known.

Is there a website that calculates this?

UPDATE WITH USE CASE:

For EtherDelta's contract (link) how can I determine what would be the maximum possible gas consumption for calling a specific method (say: the 'approve' method), so that I can tell what is the minimum safe gas limit that would never fail?


texts: Execution difference of method call in MainNet vs TestNet

texts:
I was looking at the new smart contracts submitted list on Etherscan to pass the afternoon, and I came across this one:

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

The contract seems to be a simple game of Q&A, but I noticed the original answer could be seen in plain sight here:

https://etherscan.io/tx/0xb479a806fd83e528e635c285b7302a28f0119c4be90ed37232c385bb855f8584

The answer reads "A phonE", and I thought it would get stolen quickly, since I can't be the only one doing this. I decided to take it, contact the owner, and return it to safety. I made some tests on the TestNet to see if everything worked (you need to send 1 ETH to submit a message), and it went fine. This is the testing contract address, you can check the transactions to see the process I was going to follow:

https://ropsten.etherscan.io/address/0x69e0d22469f654467bcf5c021f3e2162df96e099

As you can see, everything went fine, so I decided to do it on the MainNet. However, even though the messages and all are correct, it ate my ETH and nothing happened. I have accepted the loss of the Ether, but I am wondering, why would it not work, even tho it did on the TestNet?


texts: I'm getting an error when i have more than 3 indexed arg for an event

texts:
I want to add all the arguments for my event to be indexed

event TokenPurchase(
  address indexed purchaser,
  address indexed beneficiary,
  uint256 indexed value,
  uint256 indexed amount,
  uint256 indexed refund_amount
);

But  im getting this error when i compile

TypeError: More than 3 indexed arguments for event.

Am I really limited to three items indexed?


texts:
I've found this in ERC223 specifications:

  NOTE: The recommended way to check whether the _to is a contract or an
  address is to assemble the code of _to. If there is no code in _to,
  then this is an externally owned address, otherwise it's a contract.

What does "assemble the code" in this context mean?

Or, how do some contract knows it's sending funds to a contract not externally owned account?

If msg.data (not sure if this the right object) is empty it's externally owned account?


texts: Ethereum Wallet shows 0 balance on Ropsten

texts:
I have latest version of Mist. As you can see here https://ropsten.etherscan.io/address/0x0227e9a68e3cf3d970247114afefa9444b9a4e09 I have 10 ethers on my account. I waited for days nodes to get updated, I even deleted chaindata and re-synced but my balance is still 0.

Does anyone knows why and how to solve it? This is very buggy software.

I'm using latest Mac OS and latest Ethereum Wallet


texts:
I am trying to set up a local blockchain and started to read about Puppeth to manage the blockchain and also read about Ganache (this one I already tested a bunch of stuff), but never heard about a compassion of both.

What is the main difference between them, talking about the CLIs only?


texts:
I'm using My ether wallet on Ropsten, Brave(Metamask Ropsten) and Remix Ropsten Injected Web3. The first transaction was successful (0.5 ether received),https://ropsten.etherscan.io/address/0x471dDAF0c395c2fA0A97e9ACA175E4757362CbF6. My ether wallet adjusted automatically gas limit from 21000 to 122206. The next transactions unfortunately fail because gas required exceeds allowance or always failing transaction.Contract execution [Reverted]. Gas limit No adjusted by My ether wallet this time.
Functions on Remix:unpause,transferOwnership,buy,fallback,transferfrom,transfer,setTokenOffering failing - gas required exceeds allowance or always failing transaction.
Where is the problem ? On my computer whether on my code here: https://ropsten.etherscan.io/address/0x471ddaf0c395c2fa0a97e9aca175e4757362cbf6#code
 Any help is really appreciate to finally solve the gas error problems.Robert


texts:
Firstly
I installed geth  and it's running
I created an account and verified keystore file in the location:

~/Library/ethereum/testnet/keystore

Then I used:

Web3.personal.newAccount('password')

Its created an account and verified the location in:

~/Library/ethereum/testnet/keystore

Both of these accounts have test ethers. how should I transfer ether between them?
How should I authenticate the transfer?

Another issue I am facing in contract deployment

truffle migrate command throws an error


texts: What happens to the ETH if the contract is canceled?

texts:
I sent ETH to a company during their ICO. The contract, on Etherscan shows, Warning! Error encountered during contract execution [Bad instruction] and the contract was canceled. My question is what happens to the ETH?? My wallet still shows that the ETH was deducted but no log of ever getting it back. What happened to it? Can I get it back?

Also tried to create a tag here "canceled-contract", but I'm too new yet.


texts:
How can I catch revert or out of gas errors in web3.py?
I'd like to call a function through web3.py and in case it gets reverted I'd like to try it again after a couple of seconds.


texts: Can you execute a contract twice in one block?

texts:
If you call a contract with two different tx from different account, can they be executed and mined in the same block?

If yes how do you guarantee order and concurrency integrity like deadlocks?


texts: Does a transaction between two accounts of an Ethereum Wallet cost fees?

texts:
I've read http://ethdocs.org/en/latest/contracts-and-transactions/account-types-gas-and-transactions.html, but just to be sure:
If I want to transfer an amount of ETH between two of my accounts (or between the Main Account Etherbase and a 2nd (3rd etc) account) in my own Ethereum Wallet (currently v0.9.0) do I need to pay gas?
(Up to date my Wallet is empty so I couldn't even try to transfer ETH inside my Wallet. Would like to transfer some ETH from kraken but Ethereum Wallet syncs VERY slow.)


texts: Why web3.eth.getAccounts().then(console.log) return empty array?

texts:
It's really weird that I got empty array after I tried to web3.eth.getAccounts().then(console.log);and I also got a warning which is ./node_modules/web3-eth-accounts/src/scrypt.js Critical dependency: the request of a dependency is an expression.
In this project I first cmd create-react-app lottery_react and then all I changed in my lottery_react folder are modifying App.js and creating web3.js file. I can't find what's wrong in these file. Please help!

I've seen this but I didn't get the error that he/she gets. I only get a warning.

This is my App.js

import React, {Component} from 'react';
import logo from './logo.svg';
import './App.css';

import web3 from './web3';

class App extends Component {
  render(){
    web3.eth.getAccounts().then(console.log);
    return (

            Edit src/App.js and save to reload.

            Learn React

    );
  }
}

export default App;

This is my web3.js file

import Web3 from 'web3';

const web3 = new Web3(window.web3.currentProvider);

export default web3;


texts: How can I handle the UniswapV2: LOCKED revert reason when calling swapETHForExactTokens on the Uniswap router2 contract

texts:
I have forked the eth mainnet onto my local machine using ganache cli and am trying to call the UNISWAP router2's SwapETHForExactTokens to swap eth for MEME tokens. I call the function from truffle console like so,
await uniRouter.methods.swapETHForExactTokens('500', address, sender, '1600952122').send({from: sender, value: web3.utils.toWei('2', 'Ether')}),

Where address = [WETH address, MEME token address],
sender = unlocked account,
and uniRouter is an abstraction of the router contract.
When I first start the cli and call the function I get 'runtime error: revert' and on any subsequent calls with varying parameters I also get 'revert reason: UniswapV2: LOCKED'. Any ideas how to solve this?


texts:
Eris is a unique architecture which has taken a very useful advantage of containerizing the data, services - contracts, js, into separate container instances themselves. With the intent of running eris inside docker, I created a docker image using the instructions on 'Getting Started' into a Dockerfile. However, upon setting a CMD/ENTRYPOINT to the instruction, eris init, I cannot create a container instance using docker run -i -t --name test_eris . This makes sense, as the eris server is connecting to the docker daemon to pull images for eris-db, eris-keys, eris-actions, etc. My question around approach to run eris server within a container?
 1. Install another docker-daemon inside the Dockerfile for the eris_image. However, this would create a container within container architecture. I suspect this might unnecessarily complicate a much desired laterally scalable architecture. Suggestions?
 2. An alternate approach I can think of is building separate container images for eris-cli, eris-db, eris-keys, etc. using the Dockerfiles from eris-ltd github repo. If this were to be the approach, what are the recommendations to ensure that upon creating a private chain, eris can function as expected, with this customer container set up?


texts: How to get Safe Low, Standard and Fast gas prices?

texts:
I was relying on web3.eth.gaPrice to get the safe gas price for my transactions, but unfortunetly this doesn't give accurate results (check eth.gasPrice is returning less value than expected).

But I can see eth-gas-station returns values that we can rely on. I had also looked at blockcypher-apis for the same. They give use values in safe Low, Standard and Fast gas prices, and hence we have a better idea of what gas price should be suitable for our transaction.

Now my question is is there any better way of getting this data, apart from using 3rd party api's. As I can figure out, the possible way seems to watch previous blocks and probably take the average of past few blocks. But I am not pretty sure if this is a good idea. And even in this case, I am not sure how to get low, standard and fast gas prices.

How to eth-gas-station and other channels providing such info get this data. Is there any option apart from crawling every block.


texts: does keccak256 and sha3 reproduce the same hash ?

texts:
I have this solidity method:

function hashData(bytes32 data) public constant returns (bytes32) {
    var hash = keccak256(data, msg.sender);
    return hash;
  }

for a data = "0x707974686f6e62" and address = "0x4c5f885b9854ce17e5620098e53f3032be002fed"

I dont get the same result using  web3.sha3(data,address)


texts: sent etc classic to my eth address on hotbit

texts: i sent my etc classic on coinbase to my eth address on hotbit. hotbit is now trying to get money from me to try and help. is there any other way to recover these tokens? i've been researching for hours with no luck.


texts:
i am learning solidity contracts and ethereum dapps. I have created a smart contract for creating a ERC20 token on using truffle dev environment.

pragma solidity ^0.5.0;

contract LearnTokens {
    string  public name = "LearnToken";
    string  public symbol = "LT";
    string  public standard = "LearnToken Token v1.0";
    uint256 public totalSupply;

    event Transfer(
        address indexed _from,
        address indexed _to,
        uint256 _value
    );

    mapping(address => uint256) public balanceOf;

    function LearnToken (uint256 _initialSupply) public payable{
        balanceOf[msg.sender] = _initialSupply;
        totalSupply = _initialSupply;
    }

    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
        require(_value <= balanceOf[_from]);

        balanceOf[_from] -= _value;
        balanceOf[_to] += _value;

        emit Transfer(_from, _to, _value);

        return true;
    } }

This is my migration file

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

module.exports = function(deployer) {
    deployer.deploy(LearnToken,100);
};

And When i try to run truffle test, it throws following error.

1) Contract: LearnToken
       sets the total supply upon deployment:

      sets the total supply to 100
      + expected - actual

      -0
      +100

I have  assumed it here that when i run truffle migrate, it sets the initial supply to 100, as i have seen in a tutorial. Am i getting this right or there is another way? TIA


texts: Should I encrypt the public key of a wallet when saving it into a file?

texts:
I'm creating an ethereum wallet and I need to save the wallet data locally at the user's computer. I am, obviously, encrypting the private key. Should I also encrypt the public key?

My main question about this is because what the user shares to get transaction is not the public key but the address, so I imagine that giving away the public key could be somehow a security threat.

Could someone please elaborate on this?


texts: Added a new GPU of different brand now all jobs fail

texts:
If anyone could help i would appreciate it.
I have a rig with two Gigabite GTX 1660 Ti 6gb and it was running well with cudo miner for 10 months, i have added an MSI GTX 1660 Ti 6gb card, now all jobs fail.
I have looked at settings and duplicated what the other cards have but no success, this is my first rig and went with cudo due to ease of use, currently i have unplugged the MSI card and it is all back working as it was.
Cudo miner does see the new card, the fans start and LED lights up on the riser board (when plugged in).
Windows 10
Cudo miner 1.0
8gb ram
celeron CPU


texts: How does the genesis.json file define the initial state of the blockchain?

texts:
I understand that the state of Ethereum is its set of accounts, either EOA's or contracts.

But the genesis.json specifies no accounts; instead it defines, e.g., difficulty and gas-limit (block).

So, why do I often see that genesis.json defines the initial state of an Ethereum-based blockchain?


texts: Predict incoming transactions to a token?

texts:
I'm trying to use the API of Etherscan.
It is possible to get all pending transfer to an address?
For example, I would like to know all pending transactions that are incoming to this token:
https://etherscan.io/token/0xbf494f02ee3fde1f20bee6242bce2d1ed0c15e47
My main idea behind it would be to know in advance who is going to buy this token and be able to predict the price pump.


texts: Can someone help me read this stat concerning "distinct miners"?

texts:
Scrolling on https://etherchain.org/ , I was looking at "distinct miners" statistics( https://stats.etherchain.org/dashboard/db/distinct-miners ).

I just can't figure out what it shows concerning the network. It's expressed as a percentage, but what does it say?


texts: How to install a Ethereum Classic Geth Client?

texts:
I was trying to install Go-Ethereum Classic in Ubuntu(VM) using the following guide
     https://github.com/ethereumproject/go-ethereum
I followed the steps as per the guide and all went fine till

$ go get -v github.com/ethereumproject/go-ethereum/...

the next command for installing Geth seems not working. while executing the command cursor blinked for a second and exits from execution.
 I checked the installation  by a geth command 'help' and it returns

geth: command not found

I also tried installation using make and it also ended up in error

How to solve this issue?
Is there any reliable source rather than https://github.com/ethereumproject/go-ethereum for the installation instructions of ethereum classic node?


texts: How can I use bitcoin block stamp as seed for random number generation?

texts: I am trying to create an ethereum based smart contract that shall generate random number. After searching around, I get to know that ethereum block stamp is vulnerable to miners hacks and false injestions. Can someone guide and explain the pros and cons of using bitcoin block stamp inside ethereum smart contract? Is it even feasible?


texts: Multiple Function Calls to Smart Contract in Same Block

texts:
I have a contract with a function that increments a value, but contains a check in a require statement to verify that the incremented value is not over a specified threshold... here's some pseudo-code of what I am referring to:
contract mycontract{

uint threshold = 5;

uint value;

function myFunction(){
   value = value + 1
   require(value <= threshold)
   //do something
}
}

What Im wondering is if there are multiple calls to myFunction() within the same block, how will this act? Im not sure how to create a bundle of transactions all within the same block to test it. If value is equal to 4 in the above example, and there are 3 calls to myFunction() in the same block, will all 3 function calls have reference to the same Value=4 or will the first call execute, increment value to 5, finish the function execution and then the second call will have Value=5 and fail the require check and third call Value=5 and fail as well?


texts: Do the Solidity v0.8 overflow checks apply to assembly operations too?

texts:
Since Solidity v0.8, the compiler has checks for {over,under}flow by default for all arithmetic operations.
Do these checks apply to assembly (yul) arithmetic operations too?


texts:
Trying to get a friend excited about smart contracts I referred him to an ethereum pyramid scheme as an easy to understand example but he only pointed out that all pyramid schemes are illegal. How should one counter that concern? If this is the wrong forum, where does one get clarity on such questions, please?

In my opinion smart pyramid contracts cannot be illegal in spite of their operation since the cards are on the table.


texts: How can I replicate the Token Tracker etherscan page using python and etherscan API?

texts: So I want to list top tokens and their associated stats, like on https://etherscan.io/tokens. Even simpler than that, how can I use the etherscan python API (or https://github.com/corpetty/py-etherscan-api) to list registered tokens and their contract addresses. Then I can do the sorting and filtering myself. If this is not possible, how can I use an etherscan json API request to get the Public Name Tag of an address?


texts: how do you check the number off transaction confirmations of an ethereum transaction using web3j?

texts: I looked through the documentation but there doesnt seem to be  mention of this. I tried to debug it and look at the status of the transaction receipt but it is always null. Is there any way to do this?


texts: What is the best way to achieve a decentralised trustless transaction involving real money and virtual money?

texts:
Is this possible that we make a real world transaction (buying goods/services for money) decentralised using Ethereum to avoid trust issues?

Example: let's take an example of virtual currency exchange, someone is selling Bitcoins, and I want to buy, we agreed on terms and price, now he asked me to transfer money to his/her bank account. I have a fear what will happen if I move money and he is not transferring Bitcoins?

Can we avoid this situation? Using a smart contract which can hold a real money and only transfer to the seller if can verify transaction on the blockchain, If not send me back.

I know Escrow contracts can do same but that will hold Ethers and value of Ether can go up and down, so there is a possibility I don't get the same amount back.


texts:
I've currently download nodejs truffle, testrpc etc etc to set up my development environment. All I need to do is demonstrate the oracle service working. I've found that I need to 'set up an ethereum bridge' through this answer. But all it says is to "set it up" which is proving to be easier said than done for me at least.  I'm not the most experienced with these things so every time I try to via PowerShell I'm unsuccessful. Here's what appears when I simply type in "npm install" when in the directory of the git I've cloned.

npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but npm-shrinkwrap.json was generated for lockfileVersion@0. I'll try to do my best with it!

> sha3@1.2.0 install C:\Users\User\desktop\ethereum-bridge\node_modules\sha3
> node-gyp rebuild

C:\Users\User\desktop\ethereum-bridge\node_modules\sha3>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Users\User\AppData\Local\Programs\Python\Python36\python.EXE", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:170:21)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\User\desktop\ethereum-bridge\node_modules\sha3
gyp ERR! node -v v9.6.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sha3@1.2.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sha3@1.2.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2018-03-06T16_12_56_237Z-debug.log

If anyone could provide a foolproof explicit tutorial of how to properly download this thing so I could at least get started, I'd be eternally grateful.


texts:
I am new in Ethereum. I set up all the things as per guidelines but when I try geth help command it gives an error :

  -bash: geth: command not found in OS X EI Capitan

Edit:
the link which I follow

Help me to install geth.

Thanks in advance.


texts: mist syncing is in discrepancy with node log

texts:
I am facing a strange syncing related situation for a couple of hour now (screenshot below makes it easiest to understand).

Although my node is in sync with the network as per the node log (downloaded the last block) and what eth.blocknumber returns in the console mode, the mist wallet tells me I am about two hours late and references an old block number. So the wallet cannot really be used.

Here is the output of a click on MIST's "run test" :

Do you know how I can fix this please?

(I m on Ropsten)


texts: Create a blockchain platform to store students and its degree results on it

texts:
I would like to create a application on blockchain where i will store all students data and their results on blockchain

So anyone having a idea how can i do that or is that feasible to create a that type of system.

I have knowledge of PHP, NODEJS and Basic of Ethereum and Solidit


texts: How do miners decide whether to fork or not fork?

texts: How, as a technical matter, do miners express their desire to fork or not to fork? What happens with the miners that are in minority if they persist in mining on the unpopular branch?


texts: How to set a sender address when deploying a contract with Truffle?

texts:
I don't seem to find the answer to what looks like a really basic question. How does one specify a sender address when deploying a new contract using Truffle ?

My contract is owned. So most of my functions can only be called by the address that created the contract. Here is a simple contract's code to highlight the issue :

pragma solidity ^0.4.4;

contract Test {
    address owner;

    modifier restricted() {
        if (msg.sender == owner) _;
    }

    // Constructor
    function Test(){
    owner = msg.sender;
    }

    // Functions reserved to the owner
    function remove() restricted {
        selfdestruct(owner);
    }

    function getOwner() returns (address owner){
        return owner;
    }
}

Here are the tests :

var assert = require('assert');
var Test = artifacts.require('./Test.sol');

contract('Test', function(accounts){

        it('should test that the Test contract can be deployed', function(done){
            Test.new().then(function(instance){
                assert.ok(instance.address);
            }).then(done);
        });

        it('should test that the Test contract is deployed by the correct address (default)', function(done){
            Test.new().then(function(instance){
                var test = instance;
                test.getOwner.call().then(function(owner){
                    assert.equal(owner, accounts[0], 'Test owned by the wrong address');
                }).then(done);
            });
        });

        it('should test that the Test contract is deployed by the correct address (using from)', function(done){
            Test.new({from: accounts[0]}).then(function(instance){
                var test = instance;
                test.getOwner.call().then(function(owner){
                    assert.equal(owner, accounts[0], 'Test owned by the wrong address');
                }).then(done);
            });
        });

Running this, gives me the following result :

Contract: Test
✓ should test that the Test contract can be deployed (39ms)
1) should test that the Test contract is deployed by the correct address (default)
> No events were emitted
2) should test that the Test contract is deployed by the correct address (set)
> No events were emitted

1 passing (198ms)
2 failing

1) Contract: Test should test that the Test contract is deployed by the correct address (default):

  Uncaught AssertionError: Test owned by the wrong address
    actual : 0x0000000000000000000000000000000000000000
    expected : 0xe75bca9dadb23579e105d3a470e9ba0050ad60ce
  + expected - actual

  -0x0000000000000000000000000000000000000000
  +0xe75bca9dadb23579e105d3a470e9ba0050ad60ce

  at test/testTest.js:16:28
  at process._tickDomainCallback (internal/process/next_tick.js:129:7)

2) Contract: Test should test that the Test contract is deployed by the correct address (set):

  Uncaught AssertionError: Test owned by the wrong address
    actual : 0x0000000000000000000000000000000000000000
    expected : 0xe75bca9dadb23579e105d3a470e9ba0050ad60ce
  + expected - actual

  -0x0000000000000000000000000000000000000000
  +0xe75bca9dadb23579e105d3a470e9ba0050ad60ce

  at test/testTest.js:25:28
  at process._tickDomainCallback (internal/process/next_tick.js:129:7)

So how can I specify an address ?


texts: How to list an erc20 token in an exchange site?

texts: An erc20 token has been smart contracted in MyEtherWallet(Ropsten) and verified & published in etherscan.io. I want to list this token in an exchange I've built. Can I do it by installing a private blockchain(geth) in my exchange server and able to do rpc calls like it's done for ETH? If it is not possible, what are the other options?


texts: With a ring signature mixer, will Ethereum transactions be completely anonymous?

texts:
I was reading the Serenity PoC2. The part quoted below grabbed my attention.

Does it imply full anonymity for Ethereum transactions should I decide to use the ring signature mixer?

  Ring signature mixer – part of the test.py script now includes creating an instance of a ring signature verification contract which is designed as a mixer: five users send their public keys in alongside a deposit of 0.1 ETH, and then withdraw the 0.1 ETH specifying the address with a linkable ring signature, simultaneously guaranteeing that (i) everyone who deposited 0.1 ETH will be able to withdraw 0.1 ETH exactly once, and (ii) it’s impossible to tell which withdrawal corresponds to which deposit. This is implemented in a way that is compliant with the gas checker, providing the key advantage that the transaction withdrawing the 0.1 ETH does not need to be sent from an additional account that pays gas (something which a ring signature implementation on top of the current ethereum would need to do, and which causes a potential privacy leak at the time that you transfer the ETH to that account to pay for the gas); instead, the withdrawal transaction can simply be sent in by itself, and the gas checker algorithm can verify that the signature is correct and that the mixer will pay the miner a fee if the withdrawal transaction gets included into a block.


texts: Build an application with Truffle + React + Redux

texts:
I'm looking for some examples about how to build a Dapp with Truffle + React + Redux.

I'm able to only find this old tutorial https://www.youtube.com/watch?v=GPP6uAq15d8.

Does anyone have some other material? GitHub repo, guides.

Thank's a lot.

Working "like" a boilerplate

https://github.com/ConsenSys/Token-Factory

20/03/17 Update
Very cool https://truffle-box.github.io/


texts:
I have created an smart contract but the code in the sol file have disappeared. But the jeson file  still remains.
Can I generate my smartcontract again from ABI ?


texts: Printing into console: Events TypeError - 'watch' is not a function

texts:
Printing into console

I need to print out values like these green lines:

1) Tried returning

When I call a function that returns a string, the hexa transaction address gets printed instead of the function value.

2) Tried js

Referencing this link, I loaded the following js file in hopes to print out variable values.

var abi = /*abi interface*/
var Insurance= web3.eth.contract(abi);
var insurance = Insurance.at(web3.eth.accounts[0]);
var event = insurance.claimInsurance();

// watch for changes
event.watch(function(error, result){
    if (!error)
        console.log(result);
});
event.get(function(error, result){
    if (!error)
        console.log(result);
});

I'm getting err: TypeError: 'watch' is not a function.

Is there a way I can print out variables value from the geth console?


texts: How to concat a double quote into a string in Solidity

texts:
I am looking for a solution to concat double quotes ("") into a string in Solidity.

What I need looks like this:

'{"id":idHere,"Lname":lname,"Fname":fname}'

All I get is sth like '{\"id\":idHere,\"Lname\":lname,\"Fname\":fname}'

PS: idHere, lname and fname are variables not constant value.


texts: Is it OK to use the reset flag with every Truffle compile and migrate when using the TestRPC client?

texts:
I just spent a fair amount of time scratching my head trying to figure out why my truffle migration wasn't doing anything when trying to deploy to the TestRPC client.  It just kept saying "using network testrpc" without any subsequent status messages.  I tried running compile again, several times over the debugging session, and there were no errors.

I then did a migration with the "--reset" flag and discovered that a new smart contract file I added wasn't being found during migration ("is not defined".  Still working on that since the code and contract are there).

To save time in the future, is there any harm in always including the --reset flag when doing a Truffle compile and migrate, at least when using the TestRPC client?

What are the downsides of the using the "--reset" flag in time or gas when performing a migration on the main net, and in time on the test net (assuming there are any)?

Does the "--reset" flag cause compiles to be slower in a manner similar to "cleaning" a C++ project, which triggers the need to recompile all the source files to object files again?  With migrations, does it trigger the need to "republish" all the smart contract code to the deployment network instead of just the changed smart contracts (i.e. - just the differential)?


texts:
I was just wondering, how would I be able to make a staking function that, after one month, distributes "x"% to the locked up stake holders?
Is it something to do with now  and blocktimestamp?


texts: Trouble using Remix to deploy to BSC TestNet

texts:
Hey yall im getting this error when trying to deploy to smartchain testnet

Gas estimation failed Close Gas estimation errored with the following
message (see below). The transaction execution will likely fail. Do
you want to force sending? Internal JSON-RPC error. { "code": -32000,
"message": "gas required exceeds allowance (30000000) or always
failing transaction" }

I click okay and accept the transaction anyway but it fails and gives me:

"false Transaction mined but execution failed"

Im deploying the contract MADToken - MADToken.sol
there are also these other contracts to choose from but none of them carry the appropriate ABI or Bytecode for properly verifying the contract once its on BSC.
Contract: MADToken GitHub


texts: Deposit event is not call while contract get token

texts:
My contract
pragma solidity ^0.5.0;

contract Transfereventaction {

    event Deposit(
        address indexed _from,
        bytes32 indexed _id,
        uint _value
    );

    function deposit(bytes32 _id) public payable {
        // Events are emitted using `emit`, followed by
        // the name of the event and the arguments
        // (if any) in parentheses. Any such invocation
        // (even deeply nested) can be detected from
        // the JavaScript API by filtering for `Deposit`.
        emit Deposit(msg.sender, _id, msg.value);
    }

}

Try with

const infura = "wss://ropsten.infura.io/ws";
const web3 = new Web3(new Web3.providers.WebsocketProvider(infura));

also not working

My node js code

const infura = "ws://ropsten.infura.io/v3/id";
const web3 = new Web3(new Web3.providers.WebsocketProvider(infura));
var ClientReceipt = new web3.eth.Contract(abi ,contract_address);

ClientReceipt.events.Deposit({
    fromBlock: "latest"
}, (error, event) => { console.log("Event result is "+ event); }).on('data', (event) => {
    console.log("data event"+event); // same results as the optional callback above
}).on('changed', (event) => {
    console.log("changed event" + event) // remove event from local database
})
.on('error', console.error);

emit is not call while token transfer to contract.

My node js code is in listen and it didn't print the console message while I send token to my contract

I need to know when the contract gets token. Pls guide me in the correct way

Pls let me know if I miss anything in the code


texts: Error on deploying simple contract : It seems this transaction will fail. If you submit it it may consume all the gas you send

texts:
My smart contract code is here

// To specify what version of compiler this code will compile with
pragma solidity ^0.4.11;

contract tokensale {

  // Declaring the maximum number of tokens available for sale.
  uint public maxTokens = 10000;

  // The number of tokens you can buy for one wei (Solidity converts all unitless values from ethers to wei).
  // We will keep the default currency to be wei. It will get clearer.
  uint public tokenSwap = 10;

  // This variable, initially set to zero,  stores the number of tokens that have been bought, i.e it will
  // get incremented each time someone buys tokens.
  uint public supply = 0;

  // mapping is an equivalent to associative array. We store token balances corresponding
  // to each address that buys tokens in this mapping.
  mapping (address => uint) balance;

  // A modifier checks if a condition is met before executing a function.
  // This  modifer checks if there are tokens available before the buyTokens function is called.
  modifier isTokenAvailable () {
    require (msg.value*tokenSwap + supply <= maxTokens);     // require checks the condition and the function that
    _;                                                       // follows, denoted by the '_', is only run if the condition
  }                                                                      // is satisfied.

  // A function to check the ether balance of any address.

  // To check the token balance of any address. The external keyword allows the function
  // to be called from outside the contract. If no keyword is specified, all functions are external
  // by default..
  function balanceOf (address tokenHolder) external constant returns (uint) {
    return balance[tokenHolder];
  }

  // A function to buy tokens accesible by any address
  // The payable keyword allows the contract to accept ethers
  // from the transactor. The ethers to be deposited is entered as msg.value
  // (which will get clearer when we will call the functions in browser-solidity)
  // and the corresponding tokens are stored in balance[msg.sender] mapping.
  // underflows and overflows are security consideration which are
  // not checked in the process. But lets not worry about them for now.

  function buyTokens () external
  payable
  isTokenAvailable {
    uint tokensAmount = msg.value * tokenSwap;    // At this point, msg.value is in wei.
    balance [msg.sender] += tokensAmount;
    supply += tokensAmount;
  }
}

When I  deploying this code it shows me the error

  it seems this transaction will fail. If you submit it it may consume all the gas you send

I'm not sure what is wrong in this contract code. I have tried with different gas amount lower to higher but still same error.

Here is the output


texts: Sending Transaction From the created contract address

texts:
I am trying to deploy my Roadmap contract from the address of another newly built contract with Truffle.
I tried to do something like this:
module.exports = function(deployer) {
      deployer.deploy(MilestoneBased, RoadmapDelegate.address).then(function() {
        return deployer.deploy(Roadmap, {from: MilestoneBased.address});
  });

But I'm receiving an error "Sender account not recognized". How could I solve it? Thanks.


texts: What happens if someone DOS's my infura api link?

texts:
I have an infura link, and put it on my frontend as the default provider url.
What happens if someone DOS's that link and uses up the daily api request limit? It's unclear how infura protects against this.


texts:
I've been reading about Ethereum and it's fundamentals for a while now.
I wonder what is difference between Ethereum and InterPlanetary File System ?


texts: I have a private etherum node setup in local machine and I want to try geth export command. For this I need to specify the .rlp file . Can anybody help me to locate the .rlp file.


texts: List Ethereum transactions to: and from: in one const

texts:
I would like to list all the transactions to and from my ERC-20 Ethereum address, i can only seem to list to or from, but not both at the same time. Is there another filter I could use or way to re-structure the statement to obtain both values in one const? Thanks

const transactions = await Token123.getPastEvents('Transfer', { fromBlock: 0, toBlock: 'latest', filter: { to: this.state.account } })

and

const transactions = await Token123.getPastEvents('Transfer', { fromBlock: 0, toBlock: 'latest', filter: { from: this.state.account } })

Here is how I am viewing the results:

                { this.state.transactions.slice().reverse().map((tx, key) => {
                  return (

                      {tx.returnValues.to}
                      {window.web3.utils.fromWei(tx.returnValues.value.toString(), 'Ether')}

                  )
                }) }

Using: "web3": "1.0.0-beta.55"


texts: Get an error: insufficient funds for gas * price + value

texts:
I need to send erc20 tokens from one address to another, provided that the token balance is not empty. I check the balance as follows:

const balance = contractInstance.methods.balanceOf (walletAddress) .call (function (err, result) {
       //console.log(err)
if (result> 0) {
console.log ("result")
}

If there are 3 tokens on the account, then the result variable is 3000000000000000000
After that, I want to send all tokens from this account to my other account:

web3.eth.getTransactionCount (fromAddress)
  .then ((count) => {
    let rawTransaction = {
      'from': walletAddress,
      'gasPrice': web3.utils.toHex (20 * 1e9),
      'gasLimit': web3.utils.toHex (41000),
      'to': tokenAddress,
      'value': '0x' + result.toString('hex'),
      'data': contract.methods.transfer (fromAddress, amount) .encodeABI (),
      'nonce': web3.utils.toHex (count)
    }

But in the end I get the error insufficient funds for gas * price + value, how do I correctly convert the result variable to send tokens?


texts: Why are keys hashed in Merkle Patricia Trie?

texts:
Account addresses are hashed before they are recorded in the Patricia Merkle Trie, as well as storage slot indexes. This makes it difficult to enumerate all accounts and storage slots by scanning the Patricia Merkle Trie.

Why not storing the addresses and indexes in clear?


texts: Is it possible to access struct field from in-line assembly (Yul) when using ABIEncoderV2?

texts:
Is it possible to access struct field from Yul? Ideally it could look like this:
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

contract Sample {
    struct S {
        uint256 n;
        bytes b;
    }
    function foo(S memory s) external {
        uint256 len;
        assembly {
            len := mload(s.b);
        }
    }
}

If no, then what is the best way to access s.b fiels?

Define variable in solidity: bytes memory localB = s.b;
Some other way.


texts: Get the value of the mapping and array from solidity to javascript

texts:
I have this dummy contract. How can I get the value of the whole Positions array and mapping positionIdsOf in plain javascript?
contract DummyContract{
    mapping(address => uint256[]) public positionIdsOf;
    Position[] public positions;
}

When I try to do this
const contract = new Contract(addressOfDummyContract)
const positions = contract.positions()

It always requires passing the index into the function to get the value at the specific index but I would like to get the whole array, same with the mapping.


texts: Schedule an execution of a function in Solidity

texts:
I am new to solidity and to smart contracts,
i couldn't find a great resource describing how the execution of a function in the future really work behind the scenes and how to implement it.
I'd appreciate any help


texts: How to clean up unused meta mask event listeners

texts:
If I register a meta mask event listener using:
provider.on('accountsChanged', accounts => {
  console.log('accounts:', accounts)
})

Is there a way to clean this listener? I'm use Vue.js which means if the listener is registered upon loading of the component it's gonna register a new listener every time the component is loaded. I could use a custom workaround, checking if the listener has already been registered but maybe there's a proper way to do this that I haven't found in the metamask documentation yet. Thanks for the help!


texts: Why is remix telling me "expected primary expression" where I declared my modifier?

texts:
Why is remix telling me "expected primary expression" when I declare my modifier?

contract Autos {

// <-------- EXTENDED CONSTRUCTOR FOR TEST PURPOSES ----------->

constructor() public {

address owner;
owner = msg.sender;

bool ifmember;
mapping(address => bool) members;

modifier onlyMember {
    require(msg.sender == owner || members[msg.sender] == true);
    _;
    }

function addMember(address _address) public onlyMember {
    ifmember = members[_address];
    }

}

// <--------------------- END CONSTRUCTOR --------------------->

When I create a new SOL with just the following, I get no error:

pragma solidity ^0.4.24;

contract Autos {

address public owner;
mapping(address => bool) members;

modifier onlyMember {
    require(msg.sender == owner || members[msg.sender] == true);
    _;
    }

}


texts:
Can we convert Enum Value to string in Solidity?
Which is more efficient to use in terms of GAS, ENums or CONST ?


texts: Transactions appearing in geth but not broadcasted

texts:
Transactions sent to my own geth node sometimes get stuck in the node for hours, before eventually being broadcasted.
I am using geth 1.10.1. Transactions are sent with high gas and the expected nonce.
Why are these transactions not broadcasted?
Thanks!


texts: Nowadays there is a lot of discussion about Bitcoin hashed time locks which would unleash some new applications like atomic swaps. In Bitcoin every new logic must be implemented at client-code level while in Ethereum some flexibility is allowed by contract code. Can atomic swaps be implemented with user code in Ethereum?


texts: What's required to do header-based ("SPV") mining possible in Ethereum?

texts:
In Bitcoin, one can start mining by just including the header of the previous block into the new block without fully validating it. This is risky, but has speed improvements (being able to start mining sooner).

Is this type of mining possible in Ethereum? What are the requirements? Does the DAG or other hashes involved make this impossible? Or is it equally possible?


texts: Why don't gas calculations take into account array size anymore?

texts: I clearly remember that a couple of months ago when I tried to push some items into a storage array each consecutive 'array-pushing-transaction' took more gas to execute. In other words, it was increasingly expensive to use arrays. Now it seems that the things have changed -- gas calculations dont't take into account array size anymore. I'm just curious when did these changes took place and what was the reason behind such limitation?


texts: Why does Remix / Metamask sometimes fail to publish a contract

texts:
When I paste my contract into Remix and try to Create it, I occasionally get:

callback contain no result Error: SyntaxError: Unexpected token < in JSON at position 0

If I click create a few more times, it usually works and the Metamask popup appears.

Then, sometimes the transaction will succeed, but sometimes Metamask will give me the same error Unexpected token < in JSON at position 0.

But sometimes it works. All with the same code pasted into the Remix window. What could be going wrong? I'm on Rinkeby.

It always works when using the JVM.


texts: Write contract data for others to get reward

texts:
I want to design a business model that includes:

An IoT device, it has a address and signed data to write into smart contract, but it cannot directly connect to the ethereum network, and also its address balance is zero.
A smart contract owner by the IoT device manager.
An ethereum node, which can write data for the iot device for reward.

So I write the following solidity sample code.

contract Storage
{
    mapping(address => string[]) dataOfAddr;
    function writeData(address _addr, string _data, uint8 v, bytes32 r, bytes32 s) payable public returns(uint)
    {
        require(ecrecover(sha256(_data), v, r, s) == _addr);
        dataOfAddr[_addr].push(_data);
        msg.sender.transfer(1 ether); //for example
        return dataOfAddr[_addr].length;
    }
}

So that the iot device sends

contract address
(its address, data, signature(v, r, s))

to ethereum node.
Ethereum node writes data for it, and get reward from the contract.

  Now, the problem is how can the ethereum node determine it can gain
  reward? Since we can only get bytecode of contract instead of source
  code.


texts: Why the Ropsten test net I created have old transactions?

texts: I created Ropsten testnet account through Metamask. But in Etherscan, it seems that it is already used account, because it has some already made transactions. Why this happens?


texts: how to deal with large numbers in Ethereum?

texts:
I am confused with the use of large numbers in solidity, ethereum. I have some doubts please help me with them.

1) I am not able to represent the value of p using p.toNumber() but can represent it when I use p.toString(). where p is

uint256 p = msg.value

2) myToken.transfer(acc[3], 100000000000000000000, {from:acc[0]})

I am not not able to transfer a large number of tokens like in the above
it says { Error: invalid number value (arg="_value", coderType="uint256", value=100000000000000000000)

3)not able to set the initial supply with

module.exports = function(deployer) {
  deployer.deploy(DappToken, 1000000000000000000000)

but when I use "" it works, I am not able to understand the reason behind any of these but I think it's the same, please help

I assure you that the rest of the code is fine and works well for small numbers.

thanks.


texts: Mapping a string to an arbitrary data type?

texts:
It seems that Solidity can only handle mappings to elementary data types or structs. Is there some mapping that can handle arbitrary (dynamic) types for the values? Something like:

mapping(string => any) foo;

I have no clue how this would work.


texts: Unable to connect to Geth/web3 from outside AWS using public IP with Websocket

texts:
I tried RPC api to connect to Geth/web3 hosted in AWS EC2 using the public IP. But developers have disabled web3 in RPC(HTTP) Web3 api for non local connection. It means that you can only make a web3 connection using localhost or 127.0.0.1.
The other solution which I tried is using websocket. But it is somehow not working on AWS.
So the private IP of EC2 instance is 172.1.1.4 & public IP is 18.19.20.21
I issued the following command line:
./build/bin/geth --datadir ~/pupv1 console --nat=extip:18.19.20.21 --syncmode full   --rpc --rpcaddr 0.0.0.0  --rpcport 8415 --rpcapi personal,eth,net,web3b --rpccorsdomain '*'   --ws --wsaddr 172.1.1.4 --ws.port 3334 --ws.api personal,eth,net,web3   --ws.origins '*' --nousb

I can connect using localhost or private IP, but not using public IP. Also I cannot set public address as --wsaddr. That gives error:
Fatal: Error starting protocol stack: listen tcp 18.19.20.21:3334: bind: cannot assign requested address

Has anyone succeded in setting geth/web3 in AWS?


texts: Oracle (oraclize.it) with Truffle and Testrpc

texts:
As I understood in the blockchain, it is "not" possible to interact with webservices outside the blockchain. This must be done over oracles in order to verfiy that the request is secure, and the state change can be done in the blockchain. Please correct me, if I am wrong.

I am currently working with Testrpc, Truffle, and React in order to test my smart contract. Now I want to integrate oraclize.it into my environment. What is the best way to do this?

I tried to copy the testexamples into my Contract folder, but in the contract there is this reference:

import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";

How can I integrate this reference to my folder structure?

I tried to copy the following files to my contract folder:

https://github.com/oraclize/ethereum-api/

But I got a couple of errors.

What's the best way to implement Oraclize with Truffle and Testrpc/Ganache?


texts: How to stop contract execution w/o losing events

texts:
Function revert() is supposed to stop contract execution and rollback every change on blockchain except events reported. That's exactly what I need, but it seems to me it is not working as expected. In the following example, using remix.ethereum.org IDE and JS VM chain:

contract test {
    function a() public {
        L(1);
        revert();
    }

    event L(uint256 n);
}

When a() function is called on JS VM the following error appears:

... test.a errored: VM error: revert.
revert  The transaction has been reverted to the initial state.

And no event has been recorded.

Have tested assert(false), require(false) and throw(), same result.

Any idea how to stop the contract without losing event records? Thx!


texts:
I just updated to Solidity 5 and Truffle Beta and am testing my contracts in JavaScript.

I am trying to test my constructor events and want to use as per truffle-assertions documentation :

  truffle-assertions offers the possibility to create a transaction
  result object from a contract instance and a transaction hash, which
  can then be used in the other functions that the library offers.

let contractInstance = await Contract.new(); let result = await
truffleAssert.createTransactionResult(contractInstance,
contractInstance.transactionHash);

truffleAssert.eventEmitted(result, 'TestEvent');

When I run the following line of code but applied to my contract and then check the event it doesn't work anymore (but did fine with the previous version):

let result = await truffleAssert.createTransactionResult(contractInst, contractInst.transactionHash);
truffleAssert.eventEmitted(result, 'Started');

Here is the following error that is returned in the Terminal when I run truffle test:

AssertionError: Event of type ContractStarted was not emitted
    No events emitted in tx 0x8ed0e7489....

I console.log(result) and it does return a transaction hash. I'm not sure what I should do to get it to work and wonder if it might be due to truffle-assertions createTransactionResult not having been updated for the latest version? Or am I missing a line of code that I now need with the newer version?


texts: How to make sure that GET call is coming from Oracle and not some other entity?

texts:
EDIT: I need to edit the question since people did not understand what is it that I want to accomplish.  Please consider this scenario:

User uses a DAPP and initiates some smart-contract function, inputting some values.

The smart contract then makes a RESTful GET call with those values to some centralized server. No, I don't need a POST, a GET with URL parameters is all I want to use while parsing the GET call.

Centralized server processes those values that user entered.

Assuming there is no other way around for the data to travel from user to a server, what is the best way to implement the smart-contract so that the server does not get tricked into reacting to a forged GET call ?