texts:
I am trying to run a function with Remix web compiler on a contract in my private chain. Here is my contract and I am trying to run the function changeVaccinHistory:

contract PatientObjects {

    struct patientDetails{
        bytes32 firstName;
        bytes32 lastName;
        bytes32 dob;
        uint height;
        uint weight;
    }

    patientDetails details;
    address lastMSSeen;
    address vaccinsHistory;

    function PatientObjects (bytes32 firstName, bytes32 lastName, uint height, uint weight, bytes32 dob ,address lastMSseen, address vaccinHistory){
        details.firstName = firstName;
        details.lastName = lastName;
        details.height = height;
        details.weight = weight;
        details.dob = dob;
        lastMSSeen = lastMSseen;
        vaccinsHistory = vaccinHistory;
    }

    function changeVaccinHistory(address newAddress) returns(address){
        vaccinsHistory = newAddress;
        return vaccinsHistory;
    }

    function changeHeight(uint newHeight) returns (uint){
        details.height = newHeight;
        return details.height;
    }

    function changeWeight(uint newWeight) returns (uint){
        details.weight = newWeight;
        return details.weight;
    }

    function getDetails() public constant returns (bytes32, bytes32, uint, uint, bytes32, address, address){
        return (details.firstName, details.lastName, details.height, details.weight, details.dob, lastMSSeen, vaccinsHistory);
    }
}

Unforutnaly i get the error: callback contain no result Gas required exceeds limit: 4707786

I don't understand what this error means and what can i do to avoid it.


texts: How do I pick up Ether after Crowdsale? And other questions

texts:
Testnet: Rinkeby
Address token: 0xeAD7ACF95b260E4C866a036F9E792759Ba0Ad4ce
Address Crowdsale:0xf2D4B282CE60A0abBE7fb74C694A9A04087E5519
Ethers credited at the end of Crowdsale: 0x8be6c677cd26d8836bf75bf22fa651c463072a61
Token and Crowdsale implemented in OpenZeppelin 2.5

How can I take ether to the contract creator's wallet?
How to make a refund if the amount collected is less than SoftCup?
What code should I add to limit the minimum and maximum investor contribution?

The code:
pragma solidity ^0.5.5;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/crowdsale/Crowdsale.sol";
import "@openzeppelin/contracts/crowdsale/emission/AllowanceCrowdsale.sol";
import "@openzeppelin/contracts/crowdsale/validation/TimedCrowdsale.sol";
import "@openzeppelin/contracts/crowdsale/distribution/RefundableCrowdsale.sol";
import "@openzeppelin/contracts/crowdsale/validation/CappedCrowdsale.sol";

contract Sale is Crowdsale, AllowanceCrowdsale, TimedCrowdsale, CappedCrowdsale, RefundableCrowdsale {
    constructor(
    uint256 _rate,
    address payable _wallet,
    ERC20 _token,
    address _tokenWallet,
    uint256 _openingTime,
    uint256 _closingTime,
    uint256 _cap,
    uint256 _goal
  )
    AllowanceCrowdsale(_tokenWallet)
    Crowdsale(_rate, _wallet, _token)
    CappedCrowdsale(_cap)
    TimedCrowdsale(_openingTime, _closingTime)
    RefundableCrowdsale(_goal)
    public
    {
    require(_goal <= _cap);
    }

}


texts: Calling a contract from a called contract

texts:
I'm trying to make nested calls or whatever they are called. I always get out of gas exception. What am I missing?

From JS side I do caller.makeCall(firstAddress, secondAddress, {gas:300000, value: 300000000000000000}, callback)

Here are the contracts:

contract caller {
    function makeCall(address first, address second){
        first.call.gas(100000).value(200000000000000000)(bytes4(bytes32(sha3('makeCall(address)'))), second);
    }
}

contract first {
    function makeCall(address second) {
        second.call.gas(100000).value(100000000000000000)(bytes4(bytes32(sha3('make()'))));
    }
}

contract second {
    uint public x = 1;
    function make(){
        x = 2;
    }
    function(){
        x = 3;
    }
}

I've double checked everything. I've supplied  up to 3 million gas and still get out of gas exception.

Here's a tx https://testnet.etherscan.io/tx/0xf5986e85f7601e6a896eda22d72cb302d59013f9750c9997bf112acea757f839

Please help!


texts:
This used to open the parity web UI for my local node, but now the browser it says it cannot connect, as if I just entered any other bogus port:

http://127.0.0.1:8180/

I upgraded from Parity 1.7 to 2.5. Has the web UI port changed?

Accessing http//127.0.0.1:8545 and :8546 (RPC ports) has an effect (the node responds with a single line of text with further instructions in both cases).


texts: How expensive is it to manipulate the gas price?

texts:
Imagine that an evil billionaire decided to make Ethereum hard to use by making the gas very high. I'm wondering how expensive this would be to do for various timescales.

For example, manipulating the average gas price over a single minute might be pretty easy. How much would it cost to bring the average gas price up 100%?

Manipulating the average gas price by the same amount over a whole day would probably cost more. How much more?

Probably the answer depends on how many other people are submitting transactions as well. How to characterize this dependency?


texts:
I want to know how block data get added to the leveldb chaindata in Ethereum . So that i can change the pattern of block.
Basically i am creating my own private ethereum blockchain. And i want to add some prefix like "Block mined" in each and every block that is created.

Any suggestions are welcomed. Thanks in advance.


texts:
I need to access books array of Student contract in ClassRoom contract.

If i write as function readStudentStruct (uint ID) constant returns (address, uint, bool,address[]) then error

Different number of arguments in return statement than in returns declaration.
        return student.StudentNames(ID);

or if written without address[] then works fine.

pragma solidity ^0.4.0;
contract Student{

    struct stu{
        address name;
        uint age;
        bool tookTest;
        address[] books;
    }

    stu public s;

    mapping(uint => stu) public StudentNames;

    function addStudent (uint ID, address _name, uint _age,address[] books) {
        StudentNames[ID] = stu(_name, _age, false, books);
    }
    function updateStudent (uint ID) {
        StudentNames[ID].tookTest = true;
    }

    function getBooks(uint ID) returns(address[]){
        return StudentNames[ID].books;
    }

}
contract ClassRoom {
    address studentAddr;

    Student student;

    function ClassRoom(address addr) {
        studentAddr = addr;
        student = Student(addr);
    }
    function updateTookTest (uint ID) {
        student.updateStudent(ID);
    }

    //working fine
    function readStudentStruct (uint ID) constant returns (address, uint, bool) {
        return student.StudentNames(ID);
    }

   //showing error
   function readStudentStruct (uint ID) constant returns (address, uint, bool,address[]) {
        return student.StudentNames(ID);
    }
}

as per struct with address array function should worked but didn't.

why books array not coming in parent contract? or any way to get books array in parent contract?


texts: Why is my smart contract address for my token accumulating tokens?

texts: The link to my smart contract on bscscan is 0xB7EBB0715A799e5A3749DBAAF6657c10c1da07D3. You can see that the contract owns 1.8% of the total token supply. This number keeps rising. Can you explain why the token address keeps accumulating tokens. Aren't those tokens burned then? I believe that SwapAndLiquify is fully functional and working. That means that the 5% liquidity fee has nothing to do with it, right? What is maxTxAmount? Any information about why the contract address is gaining trillions of tokens, if it is a problem, and what to do about it, is most helpful. Thank you.


texts: I am developing chrome extension like metamask for the private Chain. I have generated the keys and using localStorage to store the Keys. But I am not sure whether I am going correct or not for security purpose. I read about the web storages like localStorage,sessionStorage and got confused. Some article says localStorage is safe some says not. Can someone give me a suggestion that which web store should I use and how to encrypt the keys? I know this is a very common question, but for my development which one is suitable?


texts: installed truffle but cannot run commands on commandline

texts:
followed up from previous post

I installed truffle however this is what I get

  PS C:\Users\user> npm install -g truffle C:\Users\user\AppData\Roaming\npm\truffle ->
  C:\Users\user\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.j
  s
  + truffle@4.0.5 updated 1 package in 3.018s

  PS C:\Users\user> truffle version truffle : The term 'truffle' is not
  recognized as the name of a cmdlet, function, script file, or operable
  program.  Check the spelling of the name, or if a path was included,
  verify that the path is correct and try again. At line:1 char:1
  + truffle version
  + ~~~~~~~
      + CategoryInfo          : ObjectNotFound: (truffle:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException

I have no idea why this is happening, I could run the commands if I went to node_modules/.bin/truffle but what is conflicting the commands right now?


texts:
After reviewing the relative questions. I am not keen enough in this space to discern if these questions and answers address my question. So I will submit my question in a neophyte tenor.

Sell a bundle of pre-programmed ether tokens for a network access and payment, to a vendor subscriber.

The vendor subscriber would then issue a token to their client which uses the ether token to access our network, book an appointment, and pay an network agent.

The ether token should perform three task:

1) Access a network

2) Pay a network transaction fee in ether equal to $2-3.00 USD routed to the network digital wallet

3) Credit a network Agent digital wallet in ether for services provided equal to $20-25.00 USD

Theoretically how much gas may be required to validate this block?

How much gas is required to credit the network's digital wallet with the transaction fee of ether payment equal to $2-3.00 USD.

How much gas is required to convert the for the network to connect with an ethereum exchange for the highest value and deposit the fiat in USD to the networks bank account?

How much gas is required to do the following? How can a network Agent connect to an exchange and convert ether payment in their digital wallet to $20-25.00 USD fiat and be routed to the Agent bank account?

To me this seems like a lot of smart contract activity however what is the answers? Please help. Thank you in advance.


texts: How to address dynamic array data for multiple arrays?

texts:
I have the code below -

pragma solidity ^0.4.18;

contract CA3 {

struct Student {
        uint16 age;
    uint16 income;
    uint16 score;
    uint16 attendance;
}

struct Employee {
    uint16 age;
    uint16 income;
    uint16 timeWorked;
}
Student[] public students;
Employee[] public employees;
function setStudent (uint16 _age, uint16 _income, uint16 _score, uint16 _attendan
ce) public {
   Student memory tempStudent = Student({age: _age, income: _income, score: _scor
e, attendance: _attendance});
        students.push(tempStudent);
//students.push(Student({age: _age, income: _income, score: _score, attendance: _
attendance}));

}
function setEmployee(uint16 _age, uint16 _income, uint16 _timeWorked) public {
Employee memory tempEmployee = Employee({age: _age, income: _income, timeWorked:
_timeWorked});
employees.push(tempEmployee);
}

}

I tested earlier the code without Employee and the following did show the storage for students -

var n = 2;
var startSlot = web3.toBigNumber(
    web3.sha3(web3.padLeft("0", 64), { encoding: 'hex' }));
var slot = "0x" + startSlot.add(n).toString(16);

web3.eth.getStorageAt(con.address, slot, function (err, result) {
  console.log(result);
});

But when I test with Employees I get the following -

> con.students(0)
[1, 2, 3, 4]
> con.employees(0)
[11, 12, 13]

> eth.getStorageAt(con.address,0) "0x0000000000000000000000000000000000000000000000000000000000000002"
> eth.getStorageAt(con.address,1) "0x0000000000000000000000000000000000000000000000000000000000000001"

This correctly finds the number of entries in the arrays.

> var startSlot = web3.toBigNumber(
...     web3.sha3(web3.padLeft("0", 64), { encoding: 'hex' }));
undefined
> startSlot
1.8569430475105882587588266137607568536673111973893317399460219858819262702947e+76

> var slot = "0x" + startSlot.add(n).toString(16);
undefined
> slot
"0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e564"

This works for students -

> n=0
0
> var slot = "0x" + startSlot.add(n).toString(16);
undefined
> eth.getStorageAt(con.address,slot)
"0x0000000000000000000000000000000000000000000000000004000300020001"

But how is Employee found? I assume we need to code a displacement somehow for the startslot.


texts: how can I detect if an address contained a contract that called selfdestruct?

texts:
I would like to create a web3-based JS function like this:

function hasSelfDestructed(address) {
  if (... address was a contract, but has called selfdestruct ...)
    return true
  else
    return false
}

If a contract has called selfdestruct, its code will be empty, or web3.eth.getCode(address) === '0x'. However, non-contract addresses also have empty code.

You can see a contract's code at some point in the past with web3.eth.getCode(address, blockNumber) (if you have a non-pruned full node). But short of querying all previous blocks, how would I know what past block to examine?

I suppose I could scan every transaction since block 0 and see if any transaction creates the contract. The transaction receipt has the contractAddress field to help with this. Whenever I see an attempt at contract creation, I could see if it succeeded and yielded any code at the address.

Is there another way?


texts: In Solidity, how to check whether the code is being executed on-chain or not?

texts:
I would like to write an external view function that throws when being executed on-chain, but does not throw when executing client-side. (for example when it is called through web3.js)

Is there a way to do this?


texts:
I am running a node on a Hosted root server, and will soon be synced, but I am not sure how I can now use this node to mine with my local Unix miner.

What I have

Xenon CPU with 32GB RAM
1 Terrabyte HDD
10 MBit Internet Connection
Ubuntu 16
geth 1.7.3-stable
FQDN

Compared to my lame home node this puppy is blazing through the blockchain syncing and could be done real soon. (Caution: keep your peers low)

Now in theory I need to open a incoming port on my firewall to the node for my home miner, setup the node to only accept miner connection from my IP-range, and then I should be set. (Hallo iptables)

Can anybody help me get the geth setup right?

I start my node with:

geth --identity TheNewNodeName --cache=2048 --maxpeers 12 --rpc --rpccorsdomain localhost --rpcapi debug,personal,eth,web3,miner console 2>&1 | tee /tmp/eth.log

I have also tried changing the values for --rpcaddr "127.0.0.1" --rpccorsdomain "*"

I have setup a nginx proxy on a sub-domain with a high port number that then forwards to the localhost 8545, but it seems I am missing some more ports as the initial contact gets through (according to the miner and the target iptraf) but the miner then just says
stratum Discarding incomplete response
and iptraf reports a new request on the same incoming port but a different TCP outgoing port...?

nginx conf:

server {
  listen sub.domain.tld:14949;
  location / {
    proxy_pass http://127.0.0.1:8545;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_read_timeout 60s;
  }
}


texts: How to find out if an individual trace succeeded or not

texts:
I understand that I can find if a transaction succeeded or not via the receipt status field. I'd like to do the same for individual traces, since a root tx can succeed, but child calls can fail.
My goal is to come up with a complete record from a transaction of ETH or token debits and credits by address resulting from a transaction.
See here for an example from Etherscan:

When I pull traces with the trace_transaction RPC call, I get something like this for each individual trace object returned:
{
    'action': {
        'callType': 'call',
        'from': '0xXXXXXXXXXXXXXXXXXX',
        'gas': '0x25ce48',
        'input': '0x3dea52fc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003e8000000000000000000000000000000000000000000000000077e772392b600000000000000000000000000000000000000000000000000000000000000000001',
        'to': '0xXXXXXXXXXXXXXXXXXXXX',
        'value': '0x0'
    },
    'blockHash': '0xXXXXXXXXX',
    'blockNumber': 6000030,
    'result': {'gasUsed': '0x2532ed', 'output': '0x'},
    'subtraces': 1,
    'traceAddress': [],
    'transactionHash': '0xXXXXXXXXXX',
    'transactionPosition': 45,
    'type': 'call'
}

So unless the failure is using too much gas, I don't see how I could determine if it failed (and therefore all it's child calls), which is what I'm trying to do.
Any ideas on how I can find this?


texts: window.ethereum.request does not exist on type "isMetaMask, on, removeListener"

texts:
It might be a pretty simple question for most, but how do I use the request method on window.ethereum if it does not exist? I see all sorts of properties and methods in the metamask docs, but when I go to write the code in VScode I get an error saying there is only 3 properties/methods on window.ethereum.
Is window.ethereum not fully compatible with Typescript, or am I doing something wrong? Am I missing something?
metamask docs: https://docs.metamask.io/guide/ethereum-provider.html#methods


texts:
Ok so I'm trying to figure out how smart contracts work, excuse me if I'm missing something obvious.

Smart contracts are a type of account, and are thus stored on the blockchain state. My question concerns the size of the contract code itself. If my contract consist of 1 million lines, will these 1 millions lines be stored in the blockchain for free ?

As I understand it, only computation costs gas, not storage itself. What would prevent an ill-intentioned person to create lots of never-called contracts whith millions of arbitrary lines, just to overload the blockchain ?

Thanks !


texts: What is the truffle command to send token and check balance of token?

texts:
pragma solidity ^0.4.8;

contract Token {

  string public name;
  string public symbol;
  uint8 public decimals;

  // address public owner;

  mapping (address => uint) balances;

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

  function Token(uint256 _supply, string _name, string _symbol, uint8 _decimals) {
    balances[msg.sender] = 10000;
   //  owner=msg.sender;

  }

  function sendCoin(address receiver, uint amount) returns(bool sufficient) {
    if (balances[msg.sender] < amount) return false;
    balances[msg.sender] -= amount;
    balances[receiver] += amount;
    Transfer(msg.sender, receiver, amount);

    return true;
  }
  function getBalance(address addr) returns(uint) {
    return balances[addr];
  }
}


texts: What storage is assigned to mappings in solidity?

texts:
I based some code on this - https://solidity.readthedocs.io/en/develop/types.html

When I run the code below -

pragma solidity ^0.4.18;

contract CA2 {

  mapping (uint => Student) public students;

  struct Student {
        address studentAccount;
        uint age;
        uint income;
        uint score;
        uint attendance;
  }
  uint public studentCount;

  function setStudent (uint age, uint income, uint score, uint attendance) public {
    studentCount++;
    students[studentCount]=Student(msg.sender,age,income, score,attendance);
  }

}

I get this -

    con.setStudent(10,15000, 4, 96) "0x5c23079797c41856010185fbf633bb9ffa64c363c282e4adda120b4e3af1c29c"

      eth.pendingTransactions []
      eth.getStorageAt(con.address,0) "0x0000000000000000000000000000000000000000000000000000000000000000"
      eth.getStorageAt(con.address,1) "0x0000000000000000000000000000000000000000000000000000000000000000"
      eth.getStorageAt(con.address,2) "0x0000000000000000000000000000000000000000000000000000000000000000"

con is set to the deployed contract using eth.contract(abi).at(addr).

I have two questions -

students appears to be an implicit array somehow. What dimensions are allocated in getStorageAt()?
After it runs the storage is all zero.

I had expected to explicitly define the array but I followed the code example.


texts: What is the significance of the function keccak256(abi.encode(to, ids))

texts:
I have seen a Solidity smart contract made by Polkamon, which is used to store NFT hashes, so that users can create an NFT without minting it, so that they can save Gas fees if they don't like their new NFT.
I am confused about the significance of one particular line of code, it is a require function that makes sure that a hash is found in the list of hashes that have been generated by users of the NFT platform.
require(registeredHashes[to][keccak256(abi.encode(to, ids))], "Hash not registered" );
What exactly is going on here?
Here is the rest of the smart contract:
contract SoftMinter is Ownable {
    // Mapping from address to bool, if egg was already claimed
    // The hash is about the userId and the nftIds array
    mapping(address => mapping(bytes32 => bool)) public registeredHashes;
    mapping(uint256 => bool) public alreadyMinted;

    CanMint private _nftContract;

    constructor(CanMint nftContract) public {
        _nftContract = nftContract;
    }

    function mint(
        address to,
        uint256[] memory ids,
        uint256 indexToMint
    ) public {
        require(
            registeredHashes[to][keccak256(abi.encode(to, ids))],
            "Hash not registered"
        );
        require(!alreadyMinted[ids[indexToMint]], "Already minted");
        if (registeredHashes[to][keccak256(abi.encode(to, ids))]) {
            alreadyMinted[ids[indexToMint]] = true;
            _nftContract.mint(to, ids[indexToMint]);
        }
    }

    //adding hash
    function addHash(address to, bytes32 dataHash) public onlyOwner {
        require(!registeredHashes[to][dataHash], "Hash already registered");
        registeredHashes[to][dataHash] = true;
    }
}


texts: How to get raw binary data from ethereum blockchain?

texts:
I want to get ethereum blocks as binary data and parse them manually to get raw ethereum transactions. Are there any good manuals how to do it?

UPDATE: how ethereum genesis block (at height #0) looks like in binary (hex) form?


texts: Where can I find Solidity's units and globally-available variables in Python's web3 package?

texts:
Units and globally-available variables in Solidity are described here.

Where can I find the corresponding entities inside Python's web3 package?

Specifically, I am interested in Solidity's time units (seconds, minutes, hours, etc).

I searched inside the Web3.py guide, but I have not been able to find them.

Thank you.


texts: In Solidity, how does the slot assignation work for storage variables when there's inheritance?

texts:
In a simple solidity contract, without inheritance, storage variables get assigned sequentially starting from slot 0.

But in case of inheritance, the inherited variables appear before or afterwards?


texts:
For example, the contract saves the address when token created but after that token holder could send token or all tokens to another wallet.

Is it possible to find all wallet addresses of token holders which were created by my contract?


texts:
In the description of the LES protocol

Canonical Hash Trie (CHT) structures are used by LES for quick initial syncing and secure on-demand retrieval of canonical hash mappings, block headers and total difficulty (TD) values.

How does a lightweight client supporting LES use CHT during initial sync? When a lightweight client looks for a sync start point for block headers, it does have a checkpoint, not a CHT.
How does CHT contribute to secure ODR?


texts: How to read and write file data using blockchain?

texts: I am a beginner to Blockchain. Can you suggest me some ways on how to write a file data to blockchain and how to read data from a blockchain to a file. If this cannot be done in Ethereum then on which platform it can be done? Moreover it should happen in realtime. Amount of data is very less


texts:
Please help me!. to found out the ropsten test token on the eth address,

thanks for the help.


texts: Where is the latest MetaMask hello world dapp example?

texts:
MetaMask recently added a new permissions check. I'd like a copy-pasteable hello world dapp that includes all best practices and can check the balance of the current user's ERC20 balance for some token.

The web is littered with old examples that either use the wrong version of Web3 or the old MetaMask API.

No dependencies on NodeJS, NPM, please. I'm seeking a vanilla answer.


texts: Web3.py "Unknown account" error when trying to write SC to Pancakeswap router

texts:
I started developing a small program which should allow me to buy tokens via pancakeswap router. When I try to do transaction, I get "unknow account" error. I think it might be because I should be locally 'logged' to my metamask account, but it's only my assumption. I exported my private key and tried to make an account from it using w3.eth.account.from_key(privateKey) but it didn't do anything. I also tried to do w3.toChecksumAddress(address) on all addresses but it didn't do anything. I have no idea what can I do at this point. This is my code:
binanceRPC = 'https://bsc-dataseed1.defibit.io/'
w3 = Web3(Web3.HTTPProvider(binanceRPC))

PCS_V2_ADDR = w3.toChecksumAddress(
    '0x10ED43C718714eb63d5aA57B78B54704E256024E')
PCS_ABI = #there would be pcs ABI but i needed to delete it due to character limit on stack
PCS_ROUTER_CONTRACT = w3.eth.contract(address=PCS_V2_ADDR, abi=PCS_ABI)

print(w3.isConnected())  # True

WBNB = w3.toChecksumAddress('0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c')
shitcoin = w3.toChecksumAddress('0x3ee2200efb3400fabb9aacf31297cbdd1d435d47')

nonce = w3.eth.get_transaction_count(testAccAddr)

amountIn = 0.0005

tx = {
    'nonce': nonce,
    'from': testAccAddr,
    'to': PCS_V2_ADDR,
    'gasPrice': 5,
    'gas': 165250,
    'value': w3.toWei(amountIn, 'ether')
}

w3.eth.account.privateKeyToAccount(testAccPrvKey)
print(w3.eth.accounts)  # []

txHash = PCS_ROUTER_CONTRACT.functions.swapExactETHForTokens(0, [w3.toChecksumAddress('0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c'), w3.toChecksumAddress(
    '0x3ee2200efb3400fabb9aacf31297cbdd1d435d47')], testAccAddr, 1621289953).transact(tx)  # ValueError: {'code': -32000, 'message': 'unknown account'}


texts: How to return the index value of an Enum?

texts:
I am trying to build a simple double escrow contract. I have an enum for the state:

enum State { Created, Locked, Inactive }
State public state;

When I try to interact with the contract through the truffle console, I can get the enum type to return:

but I don't understand how to make comparisons with the returned value. Can someone tell me how to compare the returned value?


texts:
I normally run the Ethereum Wallet and geth on the hard-forked chain. For The DAO ETC withdrawal, I would also like to
sync with the Ethereum Classic chain.

How do I sync the Ethereum Wallet and/or geth to the Ethereum Classic chain without affecting my hard-forked Ethereum chain?


texts: How to check if a state variable of type address is not initialized?

texts:
In contract B I need to provide a contract address before I can call functions logUint and logString. How do I check in these functions that A logger is not empty? if(!logger) and if(!address(logger)) doesn't compile.

contract A {
    function logUint(uint a);
    function logString(string a);
}

contract B {
    A logger;
    function registerLogger(address loggerAddress){
        logger = A(loggerAddress);
    }
    function logUint(uint a){
        //if(/*what do I put here*/)
        logger.logUint(a);
    }
    function logString(string a){
        //if(/*what do I put here*/)
        logger.logString(a);
    }
}


texts: Understanding Bytes16 Representation in Solidity


texts: Truffle tests not resetting account states

texts:
I've written some truffle tests that interact with the account balances.
Example:

A contract transfers X amount of ether from account A to account B.

Surprisingly the state of the accounts (especially the balances) are not reset between test cases. Meaning tests that test balance transfers cannot be deterministic. Is there a way around this?


texts: Low Peer Count For a light ethereum node

texts: I am running a Light node via Geth in a Debian OS . i am getting 1/2 max peers and for many hours of the day with 0 peers . what is the solution ? how to get atleast one peer everytime ?


texts: Custom Tokens not appearing in Mist. How do I watch for tokens?

texts: I purchased some first blood tokens and sent them to my mist wallet. They are listed under contracts, Then custom contracts. I'm trying to send some to another address and not having any luck. I created a quick 1:30 minute video explaining my dilemma. Here it is: https://www.youtube.com/watch?v=gUU0BzBXO0A


texts: Does a controller contract design for updating a contract work?

texts:
I have read this and I was wondering if this is a suitable implementation.

contract A {
    address owner;

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

    function useB() returns (bool){
        B b = new B(msg.sender);
        if (!b.call.value(msg.value)(bytes4(sha3("deposit()")))) { throw; }
        return true;

}
}

contract B {
    address owner;
    address controllingContract;
    uint balance;

    modifier onlyOwner {
        if (msg.sender != owner) { throw; }
        _;
    }
    modifier controlledContract {
        if (msg.sender != controllingContract) { throw; }
        _;
    }

    function B(address _owner) {
        controllingContract = msg.sender;
        owner = _owner;
    }
    function deposit() controlledContract{
        balance += msg.value;
    }
    function updateContract(address _updatedContract) onlyOwner {
        controllingContract = _updatedContract;
    }
}


texts: Etherscan API, the input field value of erc20 transactions is always deprecated?

texts:
I used to use ABIs to decode the input field of token transactions.
I notices recently that the input field has always the value deprecated.

You can try the example provided in Etherscan API page:

https://api.etherscan.io/api?module=account&action=tokentx&contractaddress=0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2&page=1&offset=100&sort=asc&apikey=YourApiKeyToken

If you click on the link above you can see that the value of the input is always deprecated.

I think I have missed something here?
Is there now another approach or API to bring the input and decode it?


texts: Unable to catch contract event using parity websockets

texts:
I have a contract deployed on ropsten which emits event when ether amount is deposited in it. I can see the event appearing in etherscan.

this.web3Socket = new Web3(new Web3.providers.WebsocketProvider('ws://18.221.50.19:8546'));

let contract = new this.web3Socket.eth.Contract(abi, walletAddr);

contract.events.allEvents({ fromBlock: 'latest' }, function (error: any, event: any) { console.log(error) })
    .on('data', async (log: any) => {
        console.log('Event Occured', log.event);
        if (log.event == 'Deposited') {
            // other operations
        }
    })

The parity server is running on a remote machine. When I run the code in my local machine it's able to detect the event but when I run the same code in that remote machine with the url set as 'ws://localhost:8546' it's not able to catch any event.

Parity - v1.10.6-stable-bc0d134-20180605,
Web3 - 1.0.0-beta.34


texts: Invalid JSON RPC response error when using truffle migrate + geth

texts:
I have been able to successfully deploy contracts on the ethereumjs testrpc with truffle without any issues. Now I wanted to do the same on a remote node running geth 1.6.1 but it gives me a JSON RPC error every time i try to run truffle migrate. There are no issues with ports and all ports are open. Tried setting up a fresh data directory , but same issue persists

command used in starting the geth client :-

geth --datadir /home/ubuntu/privatenet/test1 --networkid "1234" --rpcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3,web3_extended" --rpc --port 30310 --rpcaddr "0.0.0.0" --rpcport 8110 --rpccorsdomain="*" --nat "any" --unlock '0,1' console 2>> /home/ubuntu/privatenet/test1/eth8.log

my truffle.js file is as follows:-

module.exports = {
  networks: {
    development: {
      host: 'localhost',
      port: 8545,
      network_id: '*' // Match any network id
    },
    geth: {
      host: 'http://10.0.0.241',
      port: 8110,
      network_id: '1234', // Match network id
      from: '0x7824b8756cfa5131ead88e190e8adb10546fefaf' // account 0
        (default account which has been already unlocked)
    }
  }
};

command used:  truffle migrate --network geth

Result:

Compiling .\contracts\ UtilityEVEC.sol...
Compiling .\contracts\TokenWallet.sol...
Compiling .\contracts\contractContainer.sol...
Writing artifacts to .\build\contracts

Using network 'geth'.

    Running migration: 1_initial_migration.js
    Error: Invalid JSON RPC response: ""
        at Object.InvalidResponse (C:\Users\Administrator\AppData\Roaming\npm\node_modules\truffle\node_modu
    les\web3\lib\web3\errors.js:35:16)
    at XMLHttpRequest.request.onreadystatechange (C:\Users\Administrator\AppData\Roaming\npm\node_module
    s\truffle\node_modules\web3\lib\web3\httpprovider.js:115:32)
        at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\Administrator\AppData\Roaming\npm\node_modules\
    truffle\node_modules\xhr2\lib\xhr2.js:64:18)
        at XMLHttpRequest._setReadyState (C:\Users\Administrator\AppData\Roaming\npm\node_modules\truffle\no
    de_modules\xhr2\lib\xhr2.js:354:12)
        at XMLHttpRequest._onHttpRequestError (C:\Users\Administrator\AppData\Roaming\npm\node_modules\truff
    le\node_modules\xhr2\lib\xhr2.js:544:12)
    at ClientRequest.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\truffle\node_m
    odules\xhr2\lib\xhr2.js:414:24)
        at emitOne (events.js:96:13)
        at ClientRequest.emit (events.js:188:7)
        at Socket.socketErrorListener (_http_client.js:310:9)
        at emitOne (events.js:96:13)


texts:
I am trying to import a contract wallet after having deleted all the data from my laptop.

I have the keystore file so I am able to recover my main account (in theory this should give me access to the contract wallet) but when I try to import the contract wallet I get something like: "You do not own the contract...you can add it as watch only".

However, when I add the contract as watch-only and try to interact with it (execute) nothing happens.

Complete novice here. Can anyone point me in the right direction?

Thank you all

R


texts: go-ethereum: deploy contract with pub + private + key + password

texts:
I'm not sure if I create the right title.
But the problem is: I do have a public and private key from ganache network.

I want to deploy contract using go-ethereum which requires me to setup keystore file https://github.com/ethereum/go-ethereum/blob/master/accounts/abi/bind/auth.go#L33

Seems like an easy question - how to run unlock address without keystore file, just with private key and password but I cannot find solution yet (


texts: Getting "ReferenceError: unescape is not defined" when trying to call() a smart contract method from rasberry pi to a private geth network

texts:
> var contract1 = eth.contract(abi).at(address)
undefined
> contract1
{
  abi: [{.....]
 transactionHash: null,
  addRecord: function(),
  allEvents: function(),
  getPatientName: function(),
  getPatientRecord: function(),
  initialize: function(),
  patients: function()
}
> contract1.getPatientRecord(1,1)

This throws unescape not defined error.
I can run this on my ubuntu machine but not on my rasberry pi. The web3 version in geth is 0.20.1 which is the same in ubuntu. I don't know what's the issue.


texts: BIP Ethereum Key Generation -- Hardened Keys

texts:
You may know what the term hardened key is as it relates to the BIP-32 key generation method. If so would explain why the term 'hardened' is used to refer to the numbers which are about 231 through 232 - 1? Is it harder to crack with brute force hence the name?
Thank you!
SOLVED: LINKS INCLUDED IN ANSWER


texts: Is an Oracle a Smart Contract or an EOA?

texts: As provided in the Title, I am not clear about the concept connected to Oracles. I'm wondering if it is a Smart Contract or an EOA? Can somebody bring more clarity to the concept?


texts:
I am very new to Ethereum dev and I am currently following a tutorial. However, the Remix IDE seems a bit different from the one on my computer, likely because Mist has updated since the tutorial has been uploaded.
Basically, I don't know how to compile and run my code.

I tried the create button under "run" on the right navigation bar. This is the error message I am getting:creation of MyFirstContract errored: Send transaction failed: invalid address . if you use an injected provider, please check it is properly unlocked.
I don't know if this is useful but my mist is set to the Rinkeby test network.

It would be really appreciated if someone could teach me how I can run my code. :)

Thank you!


texts: How can I use Web3.js to specify a specific user?

texts:
I'm new at Web3.js.

In geth, I need to unlock an account before I use this account to send some transactions. This does make sense.

But in web3.js, I don't know how to specify the account. According to the document, I tried to send a transaction as follows:

mycontract.methods.myfunc(params).send({from: pk})

Here I just specified the from address, and it worked. But I never unlock the account or sign this transaction. Who can tell me why..


texts: How to solve insufficient funds (Ropsten)?

texts:
I have tried adjusting the Gas Limit and GWEI and I get this error. I am using infura and Ropsten. Has anyone any ideas about this?

Code -

        var rawTransaction = {"from":myAddress,
        "gasPrice":web3js.toHex(2*1e9),
        "gasLimit":web3js.toHex(7920027),
        "to":contractAddress,
        "value":"0x0",
        "data":contract.addBonus.getData(bonusType, target, year, month, day, token, bonus, bonusName, ineq),
        "nonce":nounce}

        console.log("raw txn " + rawTransaction);
        //creating tranaction via ethereumjs-tx
        var transaction = new Tx(rawTransaction);
        //signing transaction with private key
        transaction.sign(privateKey);
        //sending transacton via web3js module
    //    web3js.eth.sendRawTransaction('0x'+transaction.serialize().toString('hex'))
    //    .on('transactionHash',console.log);

       var serializedTx = transaction.serialize();

       web3js.eth.sendRawTransaction('0x'+serializedTx.toString('hex'), function(err, hash) {
       if (!err)
          console.log("hash = " + hash);
       else console.log("err = " + err);
       });

I get this error -

  err = Error: insufficient funds for gas * price + value


texts: Truffle migrate not working with 2_deploy_contracts.js

texts:
I have made a sample contract using Truffle's pet-shop. I have also added the 2_deploy_contracts.js file.

I have changed the solidity version and also the constructor() public {} to comply with the new rules of Solidity.

My Ganache is running parallelly. But, whenever I run the command truffle migrate, it returns nothing, so I believe that the command is failing.

The smart contract being used:

pragma solidity 0.5.0;

contract Election
{
    string public candidate;
    string public candidate1;

    constructor () public
    {
        candidate = "A";
        candidate1 = "B";
    }
}

Migrations.sol:

pragma solidity ^0.5.0;

contract Migrations {
  address public owner;
  uint public last_completed_migration;

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

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

  function setCompleted(uint completed) public restricted {
    last_completed_migration = completed;
  }

  function upgrade(address new_address) public restricted {
    Migrations upgraded = Migrations(new_address);
    upgraded.setCompleted(last_completed_migration);
  }
}

The code for 1_initial_migration:

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

export default function(deployer) {
  deployer.deploy(Migrations);
};

The code for 2_deploy_contracts.js:

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

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

I am using:

Truffle v5.0.4 (core: 5.0.4)
Solidity v0.5.0 (solc-js)
Node v8.12.0
Ganache v1.3.0


texts: How do I sell ETH received as mining rewards?

texts:
This seems like a simple question but how would one go about selling one's mined Ether?

I originally thought that I could just send my Ether on my local machine to a Coinbase Ethereum wallet and sell it there but when I view my address on the Coinbase wallet, it explicitly states, "Warning: Do not send ETH mining rewards or ETC directly to this address." Any thoughts? Thanks.


texts: Why the cost of executing the same function in the smart contract slightly decreases every execution time?

texts:
I am trying to deploy a simple smart contract application. My target is to build something like a calculator that accepts input values from different addresses. Such addresses are pre-determined by the contract owner during the deployment process, however, I have noticed the following:
Let us assume that the owner deployed the contract to accept three values from three different addresses the owner determined. I have noticed that the gas cost differs while executing the same function, as shown in the example below. The execution and transaction costs when address 1 submitted a value are slightly higher than the cost when address 2 submitted his values. Similarly, execution and transaction costs for address 2 are slightly higher than address3 costs.
Address 1: input was 100 , execution cost was 166705 and transaction cost was 188745
Address 2: input was 200 , execution cost was 134967 and transaction cost was 112927
Address 3: input was 300 , execution cost was 133956 and transaction cost was 111916


texts:
I signed up for a wallet here 3 days ago, and sent 1 Ether to it. Etherescan showed the transaction as complete, and a trace of my wallet address on the same site showed an amount of 1 Ether, but my wallet on EtherWallet showed 0 Ether.

It's now 3 days later and my wallet still shows 0 Ether. I have tried contacting EtherWallet using their support contact form, their email address, and even their phone number, which goes to a completely different company.

Strangely, on EthereScan, there seems to be another transaction on my wallet address showing that the deposited ethereum was moved to another address 1 day after I deposited it.

Can anyone help me out with this please?


texts: Does this function send ether from the contract or from the message sender?

texts:
Solidity newbie here...:

 function transfer(address payable to, address sender) public onlyadmin {
         to.transfer(msg.value);

     }

what I want to achieve is sending from the contract's balance so I guess this.balance should be the correct way and not msg.value? Thanks!


texts: Solidity: data type conversion from bytes to address/string/uint/int [ any library available? ]

texts:
I have a method which returns bytes type data from an external contract call. I need to convert that bytes type data into my desired output type data like address/uint/bool/string/int etc. I have tried finding conversion library but couldn't find any.
Note if I convert the bytes as a string like this string(returnData) the address type data got converted into something I'm unable to decode it. the same thing happens for another data type as well.

function getData(string memory _key) public returns (string memory _stringData, address _addressData, uint _uintData, bytes memory _bytesData, bool _boolData) {

    Delegate _delegate = Delegate(MAN.getLatestDelegateContract()); // this is my own internal machanism, skip thi please
    // Retrieve method name according to data type
    string memory _methodName = _delegate.getDataType(_key);
    // Prepare input call
    bytes memory _input = abi.encodePacked(bytes4(keccak256(abi.encodePacked("get",_methodName,"(bytes32)"))),keccak256(abi.encodePacked(_key)));
    // Make the call
    (bool success, bytes memory ret) = address(deployedEternalStorages).call(_input);
        // from the call data returned as bytes

        if (success) {
        // Return data as desired type
        if(keccak256(abi.encodePacked(_methodName)) == keccak256("address")){
            //convert bytes to address and assign into below variable
            //_addressData =
        }
        else if(keccak256(abi.encodePacked(_methodName)) == keccak256("uint")){
            //convert bytes to uint and assig into below variable
            //_uintData =
        }
        else if(keccak256(abi.encodePacked(_methodName)) == keccak256("bytes")){
            _bytesData = ret;
        }
        else if(keccak256(abi.encodePacked(_methodName)) == keccak256("bool")){
            //convert bytes to bool and assig into below variable
            //_boolData =
        }
        else{
            _stringData = string(ret);
        }
    } else {
        // Call failed revert
        revert();
    }
}

Can anybody help with any conversion library or any other way to convert the data types. Note: I'm using 0.5.0 version in my code.


texts: How can I connect to ethereum with only a web browser to monitor a contract

texts:
AFAICT it requires a node such as geth to connect to ethereum to get or change  contract state.

I only need to get state, not change state, but I want to do it only from a web browser.  I don't want to have to install an ethereum node on every device that wishes to view the state.  I also want to view and present the state in a particular way, so I don't want to use one of the blockchain browsing websites (they discourage applications using their websites anyways).

Do the ethereumjs libraries provide this capability?  If not, are there plans to build this capability?


texts: Getting "Tokens Unavailable" in 0X instant

texts:
I have deployed both 0x-launch-kit-backend and 0x-launch-kit-frontend in my local system
I can able to create a sell order. It is listed in orders
I am running things in Ropsten Testnet

In 0X Instant Html code . I replace my relayer URL in orderSource and mention networkId:3

I can get values in record in asset_pairs api

While run instant in-browser got "Tokens Unavailable".

Thanks in advance


texts: Ethereum Code Fork on Github : How to incorporate the majority of Ethereum updates quickly and seamlessly

texts: There are currently 6831 fork on go ethereum on github. Say I have made multiple code changes to go ethereum client for private ethereum purposes, How can I incorporate the majority of Ethereum updates quickly and seamlessly?


texts: Call Methods on a Contract Already deployed from Another Contract

texts:
i am new to blockchain and solidity.

im trying to understand the behaviour of the 'new' keyword in solidity.

I have a deployed contract Coin and in the coin contract you have the ability to transfer value from one address to another.

once you create the contract it will reward the first user with some value.

I dont know how to call the getBalance() from another contract. If i create a variable with new Coin(), doesn't that mean i have created a brand new instance of Coin?

How do i call methods on a contract that is already deployed from another contract.

pragma solidity ^0.4.17;

contract Coin {
    mapping (address => uint) balances;

    function Coin() public {
        balances[msg.sender] = 100;
    }

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

    function getBalance() public view returns (uint) {
        return balances[msg.sender];
    }
}


texts: Anyone know how curve fi and metamask fetch the average gas price for the transaction and how they provide the slow and fast option? I just want to know which third party they use to get these info.


texts: Destructuring function results in truffle console

texts:
I want to do something individually with the BigNumbers that are returned here, but I am having trouble assigning them to variables.

truffle(develop)> reg.getProviderCurve(addr,spec)
[ BigNumber { s: 1, e: 0, c: [ 1 ] },
  BigNumber { s: 1, e: 0, c: [ 1 ] },
  BigNumber { s: 1, e: 0, c: [ 2 ] } ]
truffle(develop)> [n,m,p] = reg.getProviderCurve(addr,spec)
TypeError: reg.getProviderCurve is not a function


texts: Is it okay to define the following smart contract that a accepts funds from two parties?

texts:
I want to deploy a smart contract that receive funds from two parties. The contract is initialized with some ethers from person (call it revealer), and another Recipient (name it fineRecipient) who should aslo deposit an amount of ethers. If the revealer call the contract with the correct preimage of a certain hash value, he gets his funds back and also the Recipient deposit. Otherwise, the Recipient can get all funds in the contract. Is the following contract is okay from security point of view ? or does it needs any modifications before testing it in real production environment?

pragma solidity 0.5.2;

contract TimedCommitment {
    address payable revealer;
    address payable fineRecipient;
    bytes32 public hash;
    uint256 public deadline;

    constructor(address payable _fineRecipient, bytes32 _hash, uint256 timeout) public payable {
        revealer = msg.sender;
        fineRecipient = _fineRecipient;
        hash = _hash;
        deadline = now + timeout;
    }

  function  deposit(uint256 amount) payable public{
         require(msg.value == amount);
         require(msg.value == fineRecipient);

    }

    // If this is called with the correct preimage, the revealer gets their funds back.
    function providePreimage(bytes calldata preimage) external {
        require(keccak256(preimage) == hash);
        revealer.transfer(address(this).balance);
       revealer.transfer(address(this).amount);
    }

    // Pay the fine to the fineRecipient if the timeout has expired.
    function refund() external {
        require(msg.sender == fineRecipient);
        require(now >= deadline);

        msg.sender.transfer(address(this).balance);
    }
}

This contract is edited from this nice answer :timed commitment using ethereum blockchain


texts: Geth and Web3js: invalid sender when sending signed transaction

texts:
Im using https://trezor.io/ to send signed transactions

I have succesfully send transactions to:

Truffle development network
Ropsten

Right now im using a private local go-ethereum node, the invocation of the signed transaction is exactly the same code as for truffle and ropsten and i get Invalid sender when sending the transaction

When doing some research about this i found that this error is produced by not having the same chainId and networkId, i check my configuration and how i ran the geth node and the chainId is the same that networkId

I have specified in the genesis.json of my geth node the chain id 10

"config": {
    "chainId": 10,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "clique": {
      "period": 15,
      "epoch": 30000
    }
  }

and i ran the node with networkId 10:

 geth --datadir node1/ --syncmode 'full' --port 30311 --rpc --rpcport 8545 --rpcaddr '192.168.1.244' --rpccorsdomain="*" --ws --wsaddr "192.168.1.244" --wsorigins "http://192.168.1.182" --wsport 8546 --wsapi 'personal,db,eth,net,web3,txpool,miner' --rpcapi 'personal,db,eth,net,web3,txpool,miner' --bootnodes 'enode://8235e42bec82ad8944dcf65b57d25b7a970d6e94f35961a188b2dfd306c6964f2d00d078e3bf1d9ccc6664112669d7ea9c04aa45a8ab9113aa8fe8a04b088f80@127.0.0.1:30310' --networkid 10 --gasprice '1' -unlock 'd770217581e0ca1265c88c9faaff81f5038b129f' --password node1/password.txt --mine console

Any ideas of why this could happen?

Im using geth 1.8 and web3 1.0-beta33

I think that it is something about the configuration of geth, because as i said, i have sent transactions to Truffle dev and Ropsten with the same code

Here is how i send the transactions (source code) https://github.com/ethereum/web3.js/issues/1669


texts: How to export extended (master) public key from MetaMask

texts:
I want to export extended public key for watch-only access to all ethereum addresses in the MetaMask HD wallet at once. It's very usefull for tracking of all portfolio/wallets in one place, especially when there are many HD addresses.

Is it possible with MetaMask? How I can do it?


texts: Ropsten transactions to my smart contract are failing

texts:
I am trying to test a simple smart contract that allows users to deposit and withdraw and I am
getting this error message on etherscan when I try to send ropsten ETH to my smart contract.
Warning! Error encountered during contract execution [Out of gas]

Code is shown below. I have also tried to increase gas limit but the TX keeps failing. Anybody have a clue why?
pragma solidity >=0.4.22 <0.8.0;

contract CommunityChest {
  function deposit() payable public {
  }

  function getBalance() public view returns (uint256) {
    return address(this).balance;
  }

  function withdraw() public {
    msg.sender.transfer(address(this).balance);
  }
}


texts: How to deploy multiple contracts which are dependent in Ethereum Wallet?

texts:
I have two contracts "college" and "department" . They are dependent contract.  How do I deploy them in Ethereum Wallet ?

Sample Code :

contract Department {
    function enroll(uint depID, address student) returns (bool ret) {
           return true;
      }
}

contract College {
    address student;
    Department dept_instance;

    function College ( address _student , address _department  ) {
        student = _student;
        dept_instance = _department;
     }

    function chooseDept ( uint id ) payable returns (bool value) {
        bool ret = student.send(msg.value);
        if (!ret)
            return dept_instance.enroll(id, msg.sender);
        else
            throw;
    }
}


texts: Receving Error "'Migrations'-- invalid sender" during deployment to BSC mainnet

texts:
I have tried each of the suggestions mentioned in the official issue pointing to this problem to no prevail in BSC MainNet.
I have had success in BSC TestNet as well as Ropsten TestNet.
However, the issue resurfaces when attempting to execute rm -rf node_modules; npm install; truffle deploy --network bsc with the truffle-config.js pointing its providerOrUrl to https://bsc-dataseed.binance.org (I have also attempted pointing providerOrUrl to https://bsc-dataseed1.binance.org).
For reference I am using my metamask wallet which is configured for the binance smart chain network.
I have also attempted to use several different versions of the HDWalletProvider.

1.2.2 - suggested by @jerrkill

1.2.3 - suggested by @eggplantzzz

1.0.18, 1.2.1, 1.2.6, 1.3.1 - by natural experimentation

As suggested by @nehal-backspace, I have also attempted to change truffle-config's const HDWalletProvider from

const HDWalletProvider = require('@truffle/hdwallet-provider');

to

const HDWalletProvider =  require('truffle-hdwallet-provider');

However, for each of the versions mentioned above, truffle was unable to fetch the package.
The above was reported while currently running Truffle version 5.3.1.
Upon upgrading to Truffle version 5.3.5 I can verify that the issue persists with @truffle/hdwallet-provider set to 1.3.1 as well as 1.2.2
Does anyone have any other suggestions?


texts: Would it be possible to integrate crypto with trading bot?

texts: You can create a trading bot in trading view and see how well your crypto would perform in a given time frame. (I can see how much money would I make if I didn't sell or how much money I would make if I use that code) Do you think would it be possible to create trading bot that work with crypto exchanges?


texts:
How are the blocks traversed? Is it using a linked list concept to traverse?

If I need to see all block details, will it traverse from the genesis block to the requested block or will it traverse from the last block to the requested block?

What is the next or previous link in all the blocks?

In case of mining, then from which block will it start to traverse to get the requested block?


texts: Querying transactions per account in Parity

texts:
I know geth doesn't provide the functionality of querying transactions of a particular account. But, does Parity provide it? Kind of a javascript function like this:

getAllAccountTransactions(account_address)

with the output being transaction hashes.


texts:
I am starting to play around with Ethereum  and smart contracts.

I was wondering is there is a way in Eth to revoke or kill of a public key you have given out?

If so, will the other party be notified or can it be done without their knowledge.


texts: Why is the receive () external payable not acting as a fallback?

texts:
I have this simple code in remix.ethereum
pragma solidity ^0.6.1;

contract SimpleWallet {

    address owner;

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

    modifier onlyOwner() {
        require(msg.sender == owner, "You are not allowed");
        _;
    }

    function withdrawMoney(address payable _to, uint _amount) public onlyOwner {
        _to.transfer(_amount);
    }

    receive () external payable {

    }

}

I try to deploy the contract with value of 10 eth in the js virtual machine using an address that has 100 eth
But I receive this
[vm]from:0xca3...a733cto:SimpleWallet.(constructor)value:10000000000000000000 weidata:0x608...c0033logs:0hash:0xc83...a1795
creation of SimpleWallet errored: VM error: revert.
revert  The transaction has been reverted to the initial state.
Note: The called function should be payable if you send value and the value you send should be less than your current balance.  Debug the transaction to get more information.

Why is that happening? The address has 100 eth, and the receive fallback function is defined, Shouldnt my contract be simply deployed with 10eth that way?


texts: UNGAS and why was GAS made available to programming smart contracts?

texts:
Hardforks, such as Istanbul, have illustrated the best practice that smart contracts should not make any assumptions about gas.

Gas costs have, can, and will change, for example: Is transfer() still safe after the Istanbul update?

There are UNGAS proposals and discussions:

  Disable opcode GAS. For CALL, CALLCODE and DELEGATECALL, remove the
  gas parameter, and instead, always set the parameter to be the current
  available gas left.

  If a call frame returns out of gas, revert all changes in current
  transaction and exit execution.

https://github.com/corepaper/ep/issues/1

https://ethereum.corepaper.org/compatibility/forward/

https://ethereum.corepaper.org/compatibility/legacy-repricing/

The UNGAS specification is short and simple, but its ramifications may be brilliantly deep.

History question for the core devs who designed Ethereum, why was GAS opcode and parameters in the EVM? It seemed to cause many subtleties; some got exposed for simple transfers.

Was UNGAS considered in the design phase? If so, what were the reasons for not adopting it?


texts:
I'm working on a c# application that reads the data from ethereum parity and parses it. As of present i managed to read the key value pairs from the files and convert them to hex. While looking at the data i couldn't find what i was looking for, that is, the block header or transaction data.

Has anyone done something similar and can help with gathering of data?

In order to read data from rocksdb i'm using the following package:
https://github.com/warrenfalk/rocksdb-sharp

Right now i have the following code:

        var options = new DbOptions().SetCreateIfMissing(false).SetErrorIfExists(false).SetCreateMissingColumnFamilies(false).IncreaseParallelism(Environment.ProcessorCount - 1).PrepareForBulkLoad();
        ColumnFamilies columnFamilies = new ColumnFamilies();
        for (int i = 0; i < 8; i++)
        {
            columnFamilies.Add("col" + i, new ColumnFamilyOptions());
        }
        var db = RocksDb.Open(options, path, columnFamilies);
        Parallel.For(0, 8, (i, state) =>
        {
            var columnFamily = db.GetColumnFamily("col" + i);
            var iterator = db.NewIterator(columnFamily);
            iterator.SeekToFirst();
            LevelDbData ethereumData = new LevelDbData();
            while (iterator.Valid())
            {
                string key = iterator.StringKey().ToHex();
                string value = iterator.StringValue().ToHex();
                ethereumData.Keys.Add(key);
                ethereumData.Values.Add(value);
                iterator.Next();
            }
        });

Thanks in advance for your help.


texts: What are the benefits and problems with Non ERC20 Tokens?

texts: I have been following various dapps based on ethereum and found one that has a 2-token model. One Token is ERC20 Standard compliant and one that is not. The one that is compliant is the one that acts like currency and the other doesnt have a monetary value. That one is just used to perform rating for individuals. I don't get what could be the benefits or problems with implementing such an idea and would like to know more. So please explain your thoughts regarding this.


texts: Can a dapp support metamask as well as other means for keystore?

texts: I am using Metamask for key storage in my dapp. My understanding is that the Metamask app injects a web3 object and handles all the signing functions where needed by itself. But Metamask currently provides support for chrome and firefox only (to my knowledge) and firefox plugin has some problems still (I get weird errors and plugin hangs up sometimes). I am not sure if there is android support either yet. So I want there to be alternative option to use either metamask or sign everything by asking user for key. I dont know how to the latter and if its possible to do both in same app.


texts: How to upgrade Solidity version in geth or ethereum private blockchain

texts:
I have built my private blockchain of ethereum and i'm curious to know that how can i upgrade to new version of solidity within geth so that we also can develop smart contract on newer version as ethereum do.

Thanks


texts:
I am trying to test different ways of invoking methods of other contract i.e. through an object (works) and through the address (not working).

pragma solidity ^0.5.1;

contract test1 {
    function f(int x) public payable returns (int){ return x;}
}

contract test2 {
    address payable k;
    function testA(address _add1) public {
        test1 a = test1 (_add1);
        uint amount = 500;
        a.f.value(amount)(2);
    }
    function testB(address payable _add1) public {
        uint amount = 500;
        k= _add1;//this semi colon was missing
        k.f.value(amount)(2);
    }
}

I am getting following error message in testB function:

  solc test1.sol ......test1.sol:19:9: Error: Member "f" not found or not
  visible after argument-dependent lookup in address payable.
          k.f.value(amount)(2);
          ^-^

Somebody please guide me.

Zulfi.


texts:
I'd like to add Web3 integration to an Electron app.  I found a Brave Browser fork of Electron that adds the MetaMask extension, but I'd prefer to stay in Electron if possible.  This brought me to MetaMascara, which looks like the tool I need.

Does MetaMascara have support for signing messages with a dialog box?

I've been poking around on https://github.com/MetaMask/mascara/tree/master/example and https://wallet.metamask.io/ but I can't quite get message signing to work right.


texts: What is difference between geth, myEtherWallet and etherscan

texts:
I am new to blockchain technology and learning it, there are many terms of blockchain which confused me like geth client, meta mask, etherscan and myEtherWaller.
I used geth it's a ethereum client to create a blockchain network.


texts:
Is there anyway or method to extract the address of a linked library from the contract bytecode (not a verified contract code) or deployment transaction?

my question is about step 3:

step 1. someone deploying the SafeMath.sol and getting the address as 0x1234........

step  2. someone else linking and deploying the Test.sol which use that library, the command will look something like this :

  solc --abi --bin Test.sol --libraries SafeMath:0x1234........ -o bin

step 3. a third one go to etherscan and look at the bytecode of that deployed contract or at the deployment transaction


texts:
I have the following smart contract:

pragma solidity ^ 0.4.2;

contract Chat {

    address public user;
    address public myAddress;
    string public message;
    string public response;
    address public owner;
    uint public time;

    function Chat(address _uw, address _a, string _m, string _r) {
        user = _uw;
        myAddress = _a;
        message = _m;
        response = _r;
        owner = msg.sender;
        time = now;
    }

    function getmyAddress() constant returns(address myAddress) {
        return myAddress;
    }

    function getMessage() constant returns(string message) {
        return message;
    }

    function getUser() constant returns(address user) {
        return user;
    }

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

    function getResponse() constant returns(string response) {
        return response;
    }

    function getTime() constant returns(uint time) {
        return time;
    }

    function setResponse(string r) {
        if (msg.sender == user) {
            response = r;
        }
    }

}

I would like to keep it as cheap as possible because I'm going to deploy it often.
Is there any optimization to use minimum Gas as possible?

Thanks in advance!


texts: Genesis allocation and (address, balance) tuples

texts:
On go-ethereum souce code at core\genesis_alloc.go(19):

...
package core

// Constants containing the genesis allocation of built-in genesis blocks.
// Their content is an RLP-encoded list of (address, balance) tuples.
// Use mkalloc.go to create/update them.

// nolint: misspell
const mainnetAllocData = "\xfa\x04]X\u0793\r..."
const testnetAllocData = "\xf9\x03\xa4\u0080..."
const rinkebyAllocData = "\xf9\x03\xb7\u0080..."
const goerliAllocData = "\xf9\x04\x06\u0080..."

what are all these? pre-funded wallets? I thought pre-funded wallets were specified on genesis block like this:

"alloc": {"2sa2a321h8353vba12as8965r3340huk3s6a2h6e": { "balance": "10" }, ...

where can I find the code that implements the call to AddBalance() for genesis block allocation? Thx!


texts: Unable to load smart contract using web3j on android

texts: What I'my trying to do is to load already deployed smart contract and interact with it. The problem is that after my credentials are being created properly, the error is being catched but the message is empty. I' m new to adnroid, and totally don't know how to make it work. I will upload more infos but don't actually know what are exactly needed. I would be very greatfull for help.


texts:
I started mining on the testnet and my main account (Etherbase) is getting ether quickly. It started 20 min ago and already have almost 300 ether and counting, which I think is a lot of money.

Is it just fake because I am on testnet? Is it not really ether, but something which is not worth that much?


texts: 1 week to download and syn just one third of the blockchain ... despite using geth

texts:
I am a newbie, also having severel trouble downloading/syncing the blockchain.
Mist Wallet 0.81 installed, got it working about half a year ago, but not now any.

I tried a complete download using geth 1.6.5, I got the entire chain downloaded including some error messages over the two and a half days period, but starting the mist wallet, it started a new download all over again...

Now - 7 days (!) later - mist is at 1,1 Mio of 3,8 Mio, created 21 GB (!) in my chain folder and my harddrive on c: has just about 4 GB left...

I am kind of frustrated - and thankful any advice: most urgent problem appears to be

1) How do I alter the chainfolder and references that folder in mist and geth?

2) How do I get it finally get the blockchain downloaded AND accepted by mist (any log files for examples which I need to shift from one folder to another? etc?)


texts:
I want to create a new account over IPC so I have started private chain with the below command

geth --networkid=5 --datadir DataDir --ipcapi "db,eth,net,web3,personal" --ipcpath "/Users/smartSense/.ethereum/geth.ipc"
--rpc -rpcapi "eth,web3" --rpcaddr=localhost --rpcport=8545 --rpccorsdomain "*" console 2>geth.log

now I'm trying to create new account with web3 api Ref. Link : Link

var options = {
    host: '/Users/smartSense/.ethereum/geth.ipc',
    ipc:true,
    personal: true,
    admin: false,
    debug: false
};

var web3Extended = web3_extended.create(options);
web3Extended.personal.newAccount("password",function(error,result){
        if (!error)
            res.send(result);
        else
            res.send("error"+error);
});

but I got below error:

errorError: Invalid JSON RPC response: "Error: connect ECONNREFUSED 127.0.0.1:80\n    at Object.exports._errnoException (util.js:1022:11)
\n    at exports._exceptionWithHostPort (util.js:1045:20)\n    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)"

over RPC I have created successfully but over IPC i got error so any one have idea about that?


texts: Error: User contains unresolved libraries. You must deploy and link the following libraries before you can deploy a new version of User:


texts: How come "From" address is not showing in web3.eth.filter?

texts:
I'm trying to figure out how to track the activity of users of my dapp and have a "history" page for them.

For this purpose I decided to set events and track them using web3.eth.filter

This works you can see in this image there is 1 topic showing corresponding to my event. It's a hash but it's my even.

https://i.imgur.com/Rw4fYSM.png

It's not showing the from address though. How am i supposed to know which user activated the event without it?

I thought it was possible to know the from address using eth.filter because when I use it from random addresses from etherscan, I'm seeing multiple topics and one of them is the from address.

https://i.imgur.com/uw6Qhyy.png

This is a screenshot of this random transaction https://etherscan.io/tx/0x20d783d6813e27c3083609228acbcb88b3a508533c101a6393489a82a40564e4

You can see the from address is in one of the topics. How can I get that?

The first screenshot I'm using remix and testrpc.

The second screenshot I'm using metamask's injected web3 inside chrome console and mainnet with a random etherscan address.

// This is my contract

contract Test {

    event event1(uint id);
    event event2(string name);
    uint id = 1;

    function buy() public payable {

        event1(id);
        event2('testing');
        id++;

    }

}

// This is what I get when I do web3.eth.filter in remix on testrpc
// The topics are not showing the event values,
// they are showing keccak256(event1(uint)) without the values.

null[
  {
    "logIndex": 0,
    "transactionIndex": 0,
    "transactionHash": "0x81979a998ae284933bb890585020692aad9dfa27bf6b8e6425aa2c9affcdfd43",
    "blockHash": "0x5c1f608098236c1eba26b53c872cf379cd3e82079330b2d06d40c6ce4df5811b",
    "blockNumber": 2,
    "address": "0x71ea15737ce3f92e205e3a3dad0263e344d53f24",
    "data": "0x0000000000000000000000000000000000000000000000000000000000000001",
    "topics": [
      "0x84e603adc6c5752ecafe165459551af7ba28bb2e6a2bfacc9ccb8f0ae12c76e6"
    ],
    "type": "mined"
  },
  {
    "logIndex": 1,
    "transactionIndex": 0,
    "transactionHash": "0x81979a998ae284933bb890585020692aad9dfa27bf6b8e6425aa2c9affcdfd43",
    "blockHash": "0x5c1f608098236c1eba26b53c872cf379cd3e82079330b2d06d40c6ce4df5811b",
    "blockNumber": 2,
    "address": "0x71ea15737ce3f92e205e3a3dad0263e344d53f24",
    "data": "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000774657374696e6700000000000000000000000000000000000000000000000000",
    "topics": [
      "0xd61481a11e5449d64f97e1edf49aec06a9ff79cef718c30115a331a73ae49cb4"
    ],
    "type": "mined"
  }
]


texts: Is there a service to buy sell and secure crypto currency?

texts:
Can anyone help ? I have purchased Dentacoin on coinexchange and would like to move them off the exchange into a secure wallet. Im surprised there is not a person or a service being offered to do this!

Can anyone help please ?


texts: Once again something works in Remix JVM but does not work in Rinkeby. Why?

texts:
Hello Solidity Expert,
I am attempting to solve Ethernaut problem 9 titled King. Ethernaut
On Remix, when I deploy contract King and subsequently deploy contract SendContractEther with King's contract address followed by calling sendEtherToContract() I am able to successfully run King's fallback function and everything works as expected.
When I do the above on Rinkeby, nothing happens?  Why?
Thank you
pragma solidity ^0.6.0;

contract King {

  address payable king;
  uint public prize;
  address payable public owner;

  constructor() public payable {
    owner = msg.sender;
    king = msg.sender;
    prize = msg.value;
  }

  fallback() external payable {
    require(msg.value >= prize || msg.sender == owner);
    king.transfer(msg.value);
    king = msg.sender;
    prize = msg.value;
  }

  function _king() public view returns (address payable) {
    return king;
  }
}

// SPDX-License-Identifier: MIT

pragma solidity 0.7.4;

contract SendContractEther {

    address payable public contractAddress ;

    // Assign the address of the Contract
    constructor(address payable _contractAddress) payable {
        contractAddress = _contractAddress;
    }

    function sendEtherToContract() external payable {

        contractAddress.call{value: address(this).balance, gas: 3000000}("");

    }

    function etherBalance () external view returns (uint256) {

        return address(this).balance;
    }
}


texts:
While reading the OpenEthereum codebase, I encountered this type:
/// Externalities interface for EVMs
pub trait Ext {
    /// Returns the storage value for a given key if reversion happens on the current transaction.
    fn initial_storage_at(&self, key: &H256) -> Result<H256>;

    /// Returns a value for given key.
    fn storage_at(&self, key: &H256) -> Result<H256>;

    /// Stores a value for given key.
    fn set_storage(&mut self, key: H256, value: H256) -> Result<()>;

    /* more code... */

The reason it's significant is that, in order to execute EVM bytecode, the Interpreter trait specifies a parameter of this type that needs to be passed into the step function:
/// Execute a single step on the VM.
    #[inline(always)]
    pub fn step(&mut self, ext: &mut dyn vm::Ext) -> InterpreterResult {
        /* more code... */

The best I can come up with is that the Ext type abstracts away external blockchain state so that a given instance of the EVM can be given its own context?


texts:
i knew about proof of Work and proof of Stake in term of Ethereum. But recently i heard something about proof of concept in Ethereum.

Can anyone explain what it means by proof of concept? How does it different with PoW and PoS?
Or does Proof of Concept really exists in the first place?


texts: bytes32[] returns true value in remix but when i run it through web3 it returns empty Array why?

texts:
Note All other functions working perfectly

function viewAssets()public view returns(bytes32[] memory){
    return (profile[msg.sender].noOfLand);
}

//profile is a mapping on address=> bytes32[]
//it returns actual values in remix but through web3 it returns an empty array

I have tried all three statements but nothing works

AbiAnddeployedinstance.method.viewAssets().call();

AbiAnddeployedinstance.method.viewAssets.call();

AbiAnddeployedinstance.method.viewAssets();


texts: B2B Payments through Blockchain Technology

texts: what does it take for a large enterprise to shift from regular bank payments methods to Ethereum payments. How will it impact their supplies?


texts: Verifying token contract on Rinkeby etherscan

texts:
I am testing my new token contract on Rinkeby. The contract was compiled and deployed using Brownie. I am deploying the token to Rinkeby and it is compiled and deployed correctly.
However, when I try and verify my contract on Etherscan, it keeps failing with the following error:

Error! Unable to generate Contract ByteCode and ABI
Found the following ContractName(s) in source code:
Context.sol:Context, IERC20.sol:IERC20, Token.sol:Token
But we were unable to locate a matching bytecode (err_code_2)

My contract consists of multiple files (3 to be exact) and I am using Solidity compiler version 0.8.1.
I tried compiling and deploying with Byzantium, Constantinople and Istanbul EVMs. But I keep getting the same error.
I cannot use the publish_source parameter when deploying with Brownie as that requires an API key and to my knowledge there are no API keys for Etherscan Rinkeby.
Am I missing something? Or is verification not possible on Etherscan Rinkeby?


texts: contract.methods.function(arg).send() not working in browser console although same line of code working in node console

texts:
//contract abi................
const abi = [
  {
    inputs: [ [Object] ],
    stateMutability: 'nonpayable',
    type: 'constructor'
  },
  {
    inputs: [],
    name: 'number',
    outputs: [ [Object] ],
    stateMutability: 'view',
    type: 'function'
  },
  {
    inputs: [],
    name: 'retrieve',
    outputs: [ [Object] ],
    stateMutability: 'view',
    type: 'function'
  },
  {
    inputs: [ [Object] ],
    name: 'store',
    outputs: [],
    stateMutability: 'nonpayable',
    type: 'function'
  }
];

         // web3 instantiation
        const web3 = new Web3(window.ethereum);

        const retrieve = async () => {
            await ethereum.enable();

            const accounts = await web3.eth.getAccounts();
            //contract instance
            const contract = new web3.eth.Contract(abi,
                       "0x5CdA988C848d2Fb6426F05521B1FE84128323bc0");

             await contract.methods.store("572357").send({from:
                       accounts[0], gas: '1000000'});

             const num = await contract.methods.retrieve().call();
            console.log(num);

        }
        retrieve();

getting error in browser console
index.ts:205 Uncaught (in promise) Error: invalid tuple value (argument="tuple", value="572357", code=INVALID_ARGUMENT, version=abi/5.0.0-beta.153)


texts: Infinite gas estimate for empty contract

texts:
I am trying to deploy a contract with web3, and always get an error Error: exceeds block gas limit, even for correct or empty contract code.

Actually, gasEstimates always throws :
Error: gas required exceeds allowance or always failing transaction

Even for an empty contract, the gas estimate is infinite :

var compiledContract = solc.compile("pragma solidity 0.4.17; contract Contract { }");
var abi = compiledContract.contracts[':Contract'].interface;
var abiArray = JSON.parse(abi);
var bytecode = compiledContract.contracts[':Contract'].bytecode;
var gasEstimate=web3.eth.estimateGas({from : web3.eth.coinbase, data : web3.toHex(bytecode)}); throws "exceeds allowance".

Please do you know where I can be wrong ?

Thank you,
Pierre.


texts: Looking for api call to send ERC20 token over eth-wallet

texts:
I use metamask and etherscan api to get the info when a specific ERC-20 token is sent to my wallet. I would like to use API to send a specific ERC-20 token back to a given public key over API from node backend but can't find any way to do so with the current APIs.

Can this be achieved over ETH wallet or any other way?


texts: Truffle Console: Sending 3 or '3000000000000000' through Solidity function but receiver gets '0.000000000000000003' Ether

texts:
I am trying to send Ether in Ether units i.e. 3 ethers by two different techniques using truffle console:
1)truffle(development)> C1.sendTo(C2.address, 3)
and
2)truffle(development)> C1.sendTo(C2.address, 3000000000000000)
(where sendTo(...) is a method of myContract1, C1 is the object of myContract1 and C2 is the object of myContract2. But at the receiver end i.e. C2, I am always getting '0.000000000000000003'. myContract1, myContract2 and the migration file is given below:
pragma solidity ^0.5.8;
contract myContract1 {
    address owner;
    constructor() public {
        owner = msg.sender;
    }
    function sendTo(address payable receiver, uint amount) public {
       receiver.transfer(amount);
    }
    function() external payable{
     }
}

myContract2:
pragma solidity ^0.5.8;
contract myContract2 {
    //This contract will receive Ether sent by myContract1
    address owner;
    constructor() public {
       owner = msg.sender;
    }
    function() external payable {
    }
}

and the migration file is:
const myContract1 = artifacts.require("myContract1");
const myContract2 = artifacts.require("myContract2");

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

I am accessing sendTo(..) function of myContract1 through Truffle console. I want to send the amount in Ether through ‘sendTo(..)’ method but I think it is accepting the amount in Wei and printing the value in decimal point instead of whole number. Please guide me how to send the value through Truffle console so that it should be in whole number.The output is given below, currently C1 has a balance of 7 Ethers:

truffle(development)> C1bal = await web3.eth.getBalance(C1.address)
undefined truffle(development)> web3.utils.fromWei(C1bal, "ether")
'6.993999999999999997'

and similarly:

truffle(development)> web3.utils.fromWei(C2bal, "ether")
'0.000000000000000003'

Somebody please guide me.
Zulfi.


texts: I've bought 50 ethers on btc direct 2 weeks ago. I've send it to my user account on ether.li. What was not the best choice. Because now I need the private key to withdraw it. I can't remember I had to choose one or that they gave me one. Is there a way to withdraw my balance without a private key? Or is there a way to recover my private key?


texts: Solidity: Unable to insert data into Struct

texts:
Trying to store a list of struct as a mapping but unable to insert data.
pragma solidity ^0.7.6;

contract PayTree {
address payable owner;
uint public expirationTime;
uint public wordValue;
bytes32 public root;
address[] private allMerchants;
uint public startTime;
bytes32[] usedTokens;

//Stores merchant information
struct merchant {
    address addr;
    uint numOfTokens;
    bytes32[] usedTokens;
}

//initialise state variables
constructor (uint _timeout, bytes32 _root, uint _wordValue) payable {
    owner = msg.sender;
    expirationTime = block.timestamp + _timeout;
    root = _root;
    startTime = block.timestamp;
    wordValue = _wordValue;
}

//Maps Merchant ethereum address to merchant information
mapping (address => merchant) public Merchants;

function SetUpdateMerchants (bytes32 _token) private {
    var _merchant = merchant(msg.sender, numOfTokens++, usedTokens.push(_token));
    Merchants[msg.sender] = _merchant;
    allMerchants.push(_token)
}

Getting error:

ParseError: Expected Primary expression var _merchant = merchant(msg.sender, numOfTokens++, usedTokens.push(_token)); ^-^


texts: What is the difference between m/44'/60'/0'/0 and m/44'/60'/0'?

texts: When linking MyEtherWallet with a hardware wallet, there is a dropdown to select the HD derivation path. I understand that m/44'/60'/0'/0 is the default. For some reason Ledger uses m/44'/60'/0'. I'm not sure what the missing /0 means in the context of an HD wallet. What is the difference between the two derivation paths?


texts: Check if msg.sender is a specific type of contract

texts:
Is it possible to check if msg.sender is a contract of a specific type?

For example:

pragma solidity ^0.4.23;
contract Baz {

    function Baz(){
        // want this to fail
        new Foo();
    }
}

contract Bar {

    function Bar(){
        new Foo();
    }
}

contract Foo {
    Bar bar;

    function Foo(){
        // how to make sure that msg.sender is of type Bar?
        bar = Bar(msg.sender);
    }
}

I've tried this in Remix and running it Baz in remix doesn't cause any problems.


texts: (error_10) Please enter a valid data value (Must be hex.)MyEther Wallet


texts: I am presently developing a Dapp and I am now trying to deploy it on cloud. So what I do is create an EC2 instance and drop all my code there. Then I install ganache-cli there and before on my local machine I used ganache GUI and here in GUI there is an option to create a workspace so that I don't lose my data on blockchain if my system restarts at any point in time but in the case of ganache-cli everytime it starts it creates new accounts and emulates a whole new network. So how do I proceed with this?


texts: how to create array of multiple data types

texts:
Since struct cannot be output from solidity to web3js,
I'm using arrays, I could get single datatype array in the below code(userAddress), but I'm not able to take multiple value in array(userName,userTarget).Any suggestions howto would be great

Solidity:

struct Person
    {
        address userAddress;
        string userName;
        uint userTarget;
    }
     mapping (uint => person) Persons;
     uint[] public personAccounts;
     uint incr = 0;

     function setDetailse(string  data, uint target) public
    {
        uint icr = incr++;
        address _address = msg.sender;
        var person = persons[icr];

        person .userAddress = _address;
        person .userName= _vote;
        person .userTarget = target;
        person Accounts.push(icr) -1;
    }

   function getPerson() view public returns(uint[])
   {
       uint256[] memory data =  new uint256[](11);
       for(uint i = 1; i<=10 ;i++)
        {
           data[i]=personAccounts[i];
        }
       return data;
   }

web3js:

GetDetails: function(Data, account) {
  event.preventDefault();
  var dataInstance;

  web3.eth.getAccounts(function(error, accounts) {
    if (error) {
      console.log(error);
    }

    var account = accounts[0];

    App.contracts.Details.deployed().then(function(instance) {
      dataInstance= instance;
      return dataInstance.getPerson();
    }).thenfunction((numbers => {
      const [ nums ] = numbers;
      for (var i = 0; i <nums.length; i++)
    {
          console.log("address: "+nums[i]);
      }
  })).catch(function(err) {
      console.log("error executed");
    });
  });


texts: What is Parity's “warp” sync, and why is it faster than Geth "fast"?

texts:
A follow-up of one of the classic questions on this site:

  One of the answers to this question suggested using Geth's --fast flag to help quickly synchronise the block data.

Now, parity comes with a --warp flag to enable synchronization in 10 minutes.

--warp        Enable syncing from the snapshot over the network. (default: false)

How does the --warp flag work, and how does using it speed up the synchronisation? Are we syncing less data, or are we in some way performing fewer checks on its integrity or source?


texts: How does data storage on the blockchain work?

texts:
If I store file chunks in the blocks, I'm causing duplicated blocks all over the networks (I mean, my file's chunks will be in each computer on the blockchain network, So eventually I have many many copies of this file in each block of each computer). On the other hand, If I store reference to the file in the block(for example, the block will hold: Myfile.txt stores in IP: 123.123.123.123 and 11.11.11.11) each computer that has my file, can change it easily. and even If i'm checking whether 123.123.123.123 or 11.11.11.11 (my example above) changed my file, and the answer is "True" (by comparing file's hash before and after storage) , I still don't get my file, and the data storage on blockchain is pointless.

So, how does companies like Storj works? how do they store the data on the blockchain? (As I understood, storj store references on the blocks, to 3 computers that holds my file, so how do they avoid my problem which I mentioned above?)

Thanks in advance.


texts: Verify Public Key from an RSA SHA256 signature

texts:
Given an RSA SHA256 signature (obtained from encrypting a hash using an RSA Private Key), I must assert whether a provided Public Key matches this signature or not.

It is imperative that this verification occurs inside a smart contract. I haven't, however, had much luck in finding implementations of, effectively, the RSA decrypt algorithm for Ethereum smart contracts.

In case that it hasn't been done, which all points out to, what would be the best way to go about building this? As a last resort I have considered using an oracle, however that carries a lot of security risks that I wouldn't want to be meddling with.


texts: Why nodes are not discovering each other in my private network?

texts:
I have created a private network with my own Genesis file. My private network has totally 4 systems(1 bootnode and other 3 are nodes).

I am running the bootnode in v4 using these two commands.

bootnode -genkey bootnode.key For generating private key (Only for first time)

bootnode -nodekey bootnode.key --verbosity 6 Running bootnode.

This command gave me output like

UDP listener up                            self=enode://acc1105.......@[::]:11111

I am running other nodes using this command:

geth --datadir ~/.ethereum/private --networkid 98765 --fast --rpc --rpcaddr=0.0.0.0 --rpcapi="admin,debug,eth,miner,net,personal,rpc,txpool,web3" --bootnodes enode://acc1105.......@BOOT_NODE_IP:11111 console

I am getting PING/v4, PONG/v4, FINDNODE/v4, NEIGHBORS/v4 outputs in bootnode. These 3 nodes are discovering each other for sometimes and sometimes not.


texts: Curious questions for mastering accounts

texts:
I am curious that some companies give each customer an eth address for making payment and how to redirect the payment to one master account?
Save the private key of each customer? Any example?
I think the gas will be charged two times?


texts: Are calls to internal pure functions cached by Solidity?

texts:
One of my library functions calls another internal pure function like this:
library MyLibrary {
  function foo(uint256 x) internal pure returns (uint256 result) {
      // do important work
  }

  function bar(uint256 x) public pure returns (uint256 result) {
      // ...
      uint256 foo_value = foo(x);
  }
}

But foo has a small body, so I thought what if I avoided calling it? Would I save gas?
library MyLibrary {
  function foo(uint256 x) internal pure returns (uint256 result) {
      // do important work
  }

  function bar(uint256 x) public pure returns (uint256 result) {
      // ...
      uint256 foo_value;
      // do important work here instead of in "foo"
  }
}

But no, I wouldn't save gas. Both implementations cost the same. Why is that?


texts:
I sent tokens to my contract address instead of to my myetherwallet address from an address that the tokens were previously sent some time ago. Now I have no access to the amount sent to this address. The total amount of tokens was created by this contract. Can someone please help by telling me how to get it out of the contract back into myetherwallet. Thanks.

Query by ethplorer, etherscan, ethersweep produce the same result. The myetherwallet address shows the information below without the amount sent to the contract address although it is the contract address that is imported into myetherwallet.

I have to query the contract address separately to see the amount that was incorrectly sent to it.

The contract doesn’t have a private key, so I’m at a loss with how to transfer back from the contract to myetherwallet to correct the error.

0xdc22394annnnnnnnnncead6c8639d31nnnnnnnnn (myetherwallet showing all balances except the amount transferred to the contract by error)

Token           Units
GGLN            985,000
LTPB            100,000

0xb0ggggggggggggg8cd79e1bf900619gggggggggg (contract showing only the amount that was sent to it erroneously)

Token       Units
GGLN        10,000


texts: Saving String Memory Argument to Struct Array

texts:
I have the following Solidity code that compiles and tests okay, but the insurancePlan property of the Patient struct is not being saved. I've tried many variations and it is just blank (empty) when I go to access the property. Any help would be appreciated.
contract Prescription {
    // Define patient struct
    struct Patient {
        address patient;
        bool insured;
        string insurancePlan;
        Rx[] prescriptions;
    }

    // Define prescription struct
    struct Rx {
        uint cost;
        string code;
        string description;
        uint quantity;
        bool active;
        bool refill;
    }

    Patient[] public patients;

    /******************************
    * Create a new patient        *
    *******************************/
    function newPatient(address _patient, bool _insured, string memory _insurancePlan) external {
        Patient storage patient = patients.push();
        patient.patient = _patient;
        patient.insured = _insured;
        patient.insurancePlan = _insurancePlan;

        Rx storage prescription = patient.prescriptions.push();
        prescription.cost = 0;
        prescription.code = "none";
        prescription.description = "none";
        prescription.quantity = 0;
        prescription.active = false;
        prescription.refill = false;
    }

I am then accessing the information using the following method:
    /******************************
    * Return a patient            *
    *******************************/
    function getPatient(address _patient)
        public
        view
        returns(address patient, bool insured, string memory insurancePlan, Rx[] memory prescriptions)
        {
            for(uint i = 0; i < patients.length; i++) {
                if(patients[i].patient == _patient) {
                    return (patients[i].patient, patients[i].insured, patients[i].insurancePlan, patients[i].prescriptions);
                }
            }
        }


texts: Generate new address, Send and Get transaction then Check transaction

texts:
I'm just starting in the ethereum and trying to build an app using Web3 and Nodejs. I'll need your lights so I can get any idea to know how to resolve those points:

I have my own public address and would like to generate an address to each of my users
So they can pay me by sending them the generated address.
I would like to trigger the transaction to know if true or false, it has been completed.

Thank you guys !!


texts: TestRPC - Pythereum - No handlers could be found for logger "jsonrpc.manager"


texts:
I am not sure whether I interpret the information from https://ethgasstation.info/index.php page properly.

"Std Cost for Transfer $0.02"

Does it mean that cost of any ERC20 token from one wallet to any other costs $0.02?


texts: web3 deprecated - web3/ethjs etc. difference

texts: I am currently working with smart contracts and the implementation and communication to web apps using MetaMask. I am now confused about what to use and how to implement it. What exactly will be deprecated? What and how should I use it now? Can you tell me an actual and not deprecated way/tutorial to connect to MetaMask, ask for balances and connect to contracts etc.?


texts: `ecrecover` throwing out of gas error on Ropsten

texts:
Here : http://solidity.readthedocs.io/en/v0.4.21/units-and-global-variables.html , It states

  It might be that you run into Out-of-Gas for sha256, ripemd160 or ecrecover on a private blockchain. The reason for this is that those are implemented as so-called precompiled contracts and these contracts only really exist after they received the first message (although their contract code is hardcoded). Messages to non-existing contracts are more expensive and thus the execution runs into an Out-of-Gas error. A workaround for this problem is to first send e.g. 1 Wei to each of the contracts before you use them in your actual contracts. This is not an issue on the official or test net.

It is getting out of gas on Ropsten as well, I am calling a function which involves ecrecover in it and it is not being executed.

Although, the same function worked fine in truffle testing. Running the same function on Remix, get

  Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
  Error: gas required exceeds allowance or always failing transaction

Etherscan Tx : https://ropsten.etherscan.io/tx/0x229a4e16f4464809181a24a16e1db2acb82b11ac160c26a1aa5e692495fb4d4a

How can i get this function run using Ropsten?