texts: how can access to ethereum smart contract via etherscan API

texts:
i have problem to access via etherscan api to any contract. i verified the contract code and i do every step but when i want to access just give me a 0 number when have yo be 30000000.

url
https://api.etherscan.io/api?module=contract&action=getabi&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413

for example i want to read the totalSupply of that json.

UPDATE:
Solved


texts: Who gets all the token after you create an ERC20 smart contract?

texts: I am creating a ERC20 token, I want to know where will all of the tokens be stored. Are they all store in the address that deployed the contract?


texts: getting error nonce too low , but nonce is proper stuck since one day

texts:
I am working with web3.js since sometime now , but now i am stuck with nonce too low error , the nonce is proper also i have checked private key and other addresses , they also seem to proper , however when i call addNum function is gives nonce too low error

var Web3 = require('web3');
let tx = require('ethereumjs-tx');

var Web3 =  new Web3(new Web3.providers.HttpProvider("https://rinkeby.infura.io/kG4Z6EC5EsknbOqki4mz"));

let abi = [
    {
        "constant": false,
        "inputs": [
            {
                "name": "x",
                "type": "uint256"
            }
        ],
        "name": "addNum",
        "outputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "getSum",
        "outputs": [
            {
                "name": "sum",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    }
];

let contract = Web3.eth.contract(abi);
let contractAddress = "0xc8fe6f104a5076a8d3b1284cd1a48095d6f5b5cd";
let contractInstance = contract.at(contractAddress);

let defaultAccount = '0x262b76df1dcb6542aa4a19296a824f0fdd1b4b04';
let privatekey = 'ba456ad306a69c3830eed33f690e8f5b93e36cea3cd37ed9604f71b95a5ae1e3';

    var num = 2;

    var data = contractInstance.addNum.getData(num);
            sendRaw(data, function(err, hash){
                if(err)
                {
                   console.log("err "+err);
                }
                else
                {
                    console.log("hash "+hash);
                }
            });

/**
 * Function to signed and call function in solidity
 * param data
 * return (err, transactionhash)
 */
var count = Web3.eth.getTransactionCount(defaultAccount);

function sendRaw(data, callback)
{
    var rawTx  = {
        nonce: Web3.toHex(++count),
        from: Web3.toHex(defaultAccount),
        gasLimit: Web3.toHex(300000),
        gasPrice: Web3.toHex(Web3.toWei('20', 'gwei')),
        to: Web3.toHex(contractAddress),
        value: 0,
        data: data
    };
    var privateKey = new Buffer(privatekey, 'hex');
    var transaction = new tx(rawTx);
    transaction.sign(privateKey);
    var serializedTx = transaction.serialize().toString('hex');
    Web3.eth.sendRawTransaction(
    '0x' + serializedTx, function(err, result) {
        if(err)
        {
            callback(err, '');
        }
        else
        {
            callback('', result);
        }
    });
}

Also i am testing upgradable smart contract so the address is of proxy contract and abi is of logic contract


texts: How to quickly test a Solidity function?

texts: There are snippets and functions of Solidity code provided on this Ethereum Stack Exchange and other sites.  What are ways to quickly test them, possibly debug a little, and play around?


texts: Unlike SIGINT it gives no output to console except "terminated". I tried it with testnet and it seemed ok. But is it safe to do so?


texts: is ethereum a victim of new dos attack : geth 1.5 too slow

texts: After the fork occured recently my geth 1.5 client process blocks too slowly is it another DDos attack? if not how to deal with this problem


texts: Private Blockchain - Nodes Lose Connectivity

texts:
I have a private blockchain (using Parity) where initially, all the nodes talk to each other, but over time (usually 9-18 hours) they lose connectivity until they all drop off and have zero peers.  Once in a while they find each other again here and there - one of them at least.  But it drops off again just as unexpectedly.

This happens after syncing, as sync takes less than the 9 hours.

If I use reserved peers it is a little better.  Even those lose connectivity sometimes but it doesn't matter because this is not going to help with this particular project.

There are a total of 30 nodes in total.

All nodes are running on VPSes.  All nodes have 30303 and 30303/udp open.  Most nodes are on the same network.


texts: I am at the best block while downloading blockchain. Am I done?

texts:
I'm very new to this and was following a tutorial to mine ethereum and it told me to install geth and once installed use geth -rpc to sync the blockchain. So ive been running that for the past 10hrs+ and i checked https://ethstats.net/ and apparently i am on the last block. Does this mean I am done? Thanks!

EDIT: This is the tutorial, and step 7 is the syncing part. http://www.huffingtonpost.com/entry/ethereum-mining-101-your-complete-guide_us_58b6e1eee4b02f3f81e44e9f


texts: How to connect a MetaMask account to a DApp in the MetaMask Application?

texts:
I created a DApp that uses MetaMask to interact with the ethereum blockchain. The DApp works wonderfully in the desktop browser while using MetaMask as a browser extension. Now I want to confirm that my DApp is accessible from mobile phones as well. To do that, I'm using the MetaMask App where I can log into my wallet and brows to the DApp that I developed. However, to use the DApp, I first have to connect my MetaMask account to the website like this.
Now, my question is, how to connect my MetaMask account to the DApp in the MetamMask application browser like in the picture? I wasn't able able to find any buttons or setting properties to do so.
I tried to search how to connect to the DApp through the MetaMask application and found the following (source):

Notice how when you visit a Web3 site, you can connect your MetaMask account? MetaMask will never share your public address with a website unless you give it permission. This means you are always browsing privately and control the data you share with an application. It also makes it easy to browse between different applications without creating a new account each time.

This is the code that I use in my DApp to connect to MetaMask:
import Web3 from 'web3';

//current provider is the provider injected by MetaMask
let web3;

//typeof is used to check if window is defined
if (typeof window !== 'undefined' && typeof window.web3 !== 'undefined') {
  // We are in the browser and metamask is running.
  //Connect metamask to the webapp
  window.ethereum.enable();
  web3 = new Web3(window.web3.currentProvider);
} else {
  // We are on the server *OR* the user is not running metamask
  const provider = new Web3.providers.HttpProvider( 'https://ropsten.infura.io/v3/KEY');
  web3 = new Web3(provider);
}

export default web3;


texts: Recreating Solidity sha256(this) in python

texts:
I'm trying to recreate the following solidity statement in python:

sha256(this)

I have the correct hash function, but I don't know how to recreate the input "this"

Anyone know how to do this?

Thanks!


texts:
I came across the following code and found the term "pragma experimental ABIEncoderV2". Can anybody be specific in telling what this actually means?

//pragma solidity ^0.5.2;
pragma experimental ABIEncoderV2;
contract test {

struct document{
   string ipfsHash;
   string documentName;
   bytes32 accessKey;
}

struct grantAccess{
   address owner;
   address single;
}

This is a part of the code I found over the web.


texts: Fetching a snapshot of all the contracts accessible on Etherscan

texts:
I am trying to collect a large set of online contracts and came across the following statement in a research article:

Does anyone know how to access such a "snapshot of 25983 contracts"? Is it somehow hosted by Etherscan?


texts: How to transfer ico tokens to myetherwallet, Metamask programmatically

texts: I am working on an ICO site. Everything is working fine now i need to transfer ICO token to Myetherwallet and metamask wallet. Please let me know what are the best and possible ways to do this and is it possible in php?.


texts: Calling/Executing Contracts from low level languages for standalone program

texts:
Is there any way to call a contract from lower level languages (c, c++, rust, etc), say for some standalone executable/program?

Basically do all interfaces with the ethereum network have to be through the browser or Mist client?

If not does anyone have any examples/resources.


texts:
Been struggling in finding a way to estimate gas for calling a function.
I was getting the error -  Error: VM Exception while processing transaction: revert locally on ganache and getting Error: The execution failed due to an exception. on Kovan.
Here's a sample solidity function:

This is what my code looks like:
sig := []byte("withdraw(address)")
methodID := crypto.Keccak256(sig)[:4]
toAddress := common.HexToAddress(myAddr)
paddedAddress := common.LeftPadBytes(toAddress.Bytes(), 32)

var data []byte
data = append(data, methodID...)
data = append(data, paddedAddress...)

sendTo := common.HexToAddress(myAddress)

callMsg := ethereum.CallMsg{
        From:     Wallet.Address,
        To:       &sendTo,
        Gas:      0,
        GasPrice: big.NewInt(0),
        Value:    big.NewInt(0),
        Data:     data,
}
gasAmount, err := eth.EthClient.EstimateGas(context.Background(), callMsg)

Why am I getting the complaint -
Error: VM Exception while processing transaction: revert


texts: How to re-compile contracts using truffle which are updated?

texts: I deployed something in the test-net(ropsten). Later, realized that one of my contracts needs some amendments. In such cases how to compile specific contracts and deploy only that contract using truffle command?


texts: How do I handle storing coins for an app that will use an ETH token?

texts:
Im making a website thats going to use a custom token. Im new to developing using eth tokens/coins.

How do I store and access the users tokens?

What Im wondering is do I create additional addresses in my own local wallet (geth) for each user or should they come to the site already having their own wallets from elsewhere?


texts: Alleged solution for music copyright payment with smart contract

texts:
Everywhere on the internet people are blogging/bragging about how smart contract can reinforce payment to musicians/content providers (on each usage (download, listening/clicking) of the content!!), but I don't see it happen at the technology level, especially after reading this answer. So is it really possible to trigger the contract through changes in real-life outside of the blockchain?

A broader question would be, what are the restrictions on the input data into the contract each time on execution? I could certainly imagine the aforementioned reinforcement be possible if each executing node were allowed to fetch input data from the internet, but there would arise at least two problems:

since the execution time can't always be the same throughout the network, such fetched input data can hardly be checked against forgery because a faked fetch is indiscernible from a fetch at another point in time. An agreement will then never be made.
if the input data is fetched constantly from another server, that server could have huge influence on the execution, should it be centralized.


texts: web3.personal.newAccount how to get address

texts:
If I do web3.personal.newAccount("passphrase") from my code then how can I get back the address that was created using my passphrase?
Moreover can anyone tell me the difference of web3.personal.newAccount & web3.eth.accounts.create both are creating accounts and if by second method i store the key in keystore then how can I unlock the account using web3.personal.unlockAccount ?


texts: How do you create a simple fixed-size array?

texts:
I feel like this is a stupid question, but I cannot find the answer.  Readthedocs.io states:

"An array of fixed size k and element type T is written as T[k]"

But when I create the following simple code, it does not work.  Remix tells me "Member "push" not found or not visible after argument-dependent lookup in address[3] storage ref".

pragma solidity ^0.4.24;

contract Garbage {

address[3] public addresses;

function addAddress(address _address) public {

    addresses.push(_address);

}

Removing the 3 gets rid of the error, but is then no longer a fixed array.


texts: Legal Implications of Running a Swarm node in a VPS / Server

texts:
I fully support Swarm and I would like to be part of it and provide a node/farm to the Swarm network, so my questions are.

1.-While many VPS providers are fine with you running an Ethereum node many will not like the idea of unknown files being stored in one of their servers in the same way they sometimes don't like torrenting or other p2p technologies. Will running a Swarm node be as controversial for server providers as running an exit TOR node? Will they generate abuse complaints or dmca notifications that Swarm node operators would have to deal with?

2.- Currently, Storj addresses Copyright Complaints directly. https://storj.io/terms-of-use.html (See article 6). Should we expect something similar done by Swarm?


texts: What is the position of Whisper and Swarm in the Ethereum 2.0 Roadmap

texts:
Back in 2015, Ethereum vision was to be a "World Computer" relying on three main complementary technologies:

Ethereum for decentralized Logic
Swarm for decentralized Storage
Whisper for decentralized Messaging

With Ethereum 2.0 (Serenity) on its way composed of Casper FFG, Beacon chain, sharding, eWASM, I am wondering:

Is the vision still the same or the triangular model may evolve based on the current Ethereum 2.0 development
Is Swarm and Whisper development aligned with Ethereum 2.0


texts: How does the EVM resolve method ID collision?

texts: What happens if I craft an EVM binary such that the ABI sees two matching method IDs, and try to deploy the contract? Is it a valid transaction?


texts: 'dropped and replaced' ETH still missing

texts:
I have an ETH transaction that is listed as 'dropped and replaced' on Etherscan:
https://etherscan.io/tx/0x98640241cd77a4c1301c8522851ec07508ac783239c643a4a3c13b1dc55d9ea1
On Uniswap it shows as pending.
Eth still missing from my metamask wallet.  Transaction is ~10 hours old.  What do I do?


texts:
I have a webpage that talks to a smart contract on testrpc. I connect using:
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

I have deployed my contract to Ropsten Test Network with Metamask. How do I change my webpage to point to the Ropsten test network?  Is it as simple as changing the web address from "localhost" to a Ropsten web address?

Thanks!


texts: Returning static array inaccessible dynamic type

texts:
In the first contract I have:

function getArray() external view returns(uint[] memory result) {
    uint counter = 0;
    result = new uint[](3);
    for (uint i = 0; i <= 3; i++) {
        result[counter] = i;
        counter++;
    }
}

In the second contract I have somewhere:

uint[] r = contractA.getArray();

I receive

TypeError: Type inaccessible dynamic type is not implicitly convertible to expected type uint256[] storage pointer.


texts:
I have a local fork of yieldfarming.info that I add new farms/pools to. I recently setup and successfully sync'd a geth node. I pointed my metamask to it and I assumed my life would be blazing fast from now on.
When i navigate to my page, it takes a long time to load and I see these messages in my geth console:
WARN [01-02|09:39:54.177] Served eth_call                          conn=192.168.1.70:53352 reqid=2838763956 t="260.88µs"  err="execution reverted"
WARN [01-02|09:39:54.187] Served eth_call                          conn=192.168.1.70:53352 reqid=2838763958 t="229.179µs" err="execution reverted"
WARN [01-02|09:39:54.196] Served eth_call                          conn=192.168.1.70:53352 reqid=2838763960 t="141.235µs" err="execution reverted"
WARN [01-02|09:39:54.324] Served eth_call                          conn=192.168.1.70:53352 reqid=2838763988 t="140.845µs" err="execution reverted"
WARN [01-02|09:39:54.334] Served eth_call                          conn=192.168.1.70:53352 reqid=2838763990 t="138.575µs" err="execution reverted"
WARN [01-02|09:39:54.344] Served eth_call                          conn=192.168.1.70:53352 reqid=2838763992 t="144.336µs" err="execution reverted"
WARN [01-02|09:39:54.546] Served eth_call                          conn=192.168.1.70:53352 reqid=2838764020 t="290.561µs" err="execution reverted"
WARN [01-02|09:39:54.555] Served eth_call                          conn=192.168.1.70:53352 reqid=2838764022 t="317.352µs" err="execution reverted"

I launch geth like this:
geth \
    --signer=/supersecret/clef.ipc \
    --cache=4096 \
    --maxpeers=50 \
    --nousb \
    --syncmode "fast" \
    --http --http.api net,web3,eth,admin,personal \
    --http.addr "0.0.0.0" \
    --http.corsdomain "*" \
    --http.vhosts "*" \
    --ws --ws.api net,web3,eth,admin,personal \
    --ws.addr "0.0.0.0" \
    --ws.origins "*"

Could anyone recommend any settings/flags/optimizations to GETH to speed things up a bit and return less warnings/errors/retries?
Thanks so much


texts: How to import quorum 7 node accounts to metamask

texts:
I am new to quorum 7node example
I have created a DApp I want to send transaction using metamask
when I was using testrpc to connect with DApp i was able to see all 10 test accounts in metamask after loging in and  entering mnemonic
but now when I am using quorum I dont have any such mnemonic
i want to import node accounts to metamask how can i do that?
how to connect to custom rpc i mean i am sure what to enter in place of ? http:?:22000


texts: Can myetherwallet be "hacked" from the browser extension?

texts:
I'm using myetherwallet for pretty long time and like their concept - do all on the client side. So, in theory, no data is sending to the server, so even if server gets hacked - you won't lose your coins.

I have one question - in my understanding, chrome or any other browser extensions are running at same memory area. So extension can access your data such as your decrypted private key and so on.

Am I right? Please, tell me I'm wrong :)


texts: How to get an interface form smart contract

texts:
I have a Smart Contract that I deployed on the blockchain. I would like to create another smart contract that will call the first smart contract. I would like to create an interface containing method signatures of the first contract so I can use it in the caller smart contract because I don't want to copy the whole source code of the first contract to the second one.
I am not sure how to do that automatically


texts: Why does the Ethereum blockchain need a consensus network?

texts: Why does Ethereum blockchain need computers to agree on blocks?  If by means of cryptography, only the private key holder can generate the appropriate hash for a certain transaction, why not let a single miner just include the transaction in the block.  Why the need for multiple computers to validate the transaction?


texts: Use Ethereum TestRPC with Web3 IPC Provider

texts:
Can I use TestRPC only with http or can I set it up with ipc as well?
If yes - how?


texts: I hope the question is self explanatory but, basically I wonder if the Ethereum code is made in a way that id there is more miners, would that in turn allow for lower gas prices or transactions to be processed faster, in turn requiring less gas to be used?


texts: Difference in contract instance in web3 and truffle test

texts:
When I'm working whit web3 I have something like:

 var abi = [...];
var contract = new web3.eth.Contract(abi,"0x86Fa049857E0209aa7D9e616F7eb3b3B78ECfdb0");

then I use something like:

myContract.methods.myMethod(123).call(....

In truffle test I have a contract instance in hand, and I use

instance.myMethod(123)

without the "methods" indirection, what is different from the two contract instances?


texts: Is it possible to have a soldity smart contract perform a function on a predefined date (E.g. perform a payment on 2/12/2018) without requiring an external events to call the function? If yes, how would this look like in solidity?


texts: Contribute function of crowdsale is not working

texts:
I am having a crowdsale contract. I am trying to run contribute function using command: contractInstance.contribute.sendTransaction(101,{from:eth.accounts[0],value:200, gas:4000000}). It is creating a transaction hash. After mining I can see the value = 200 and to: contractAddress. But it doesn't increase the contract balance. I am getting no error. My contribute function is as:

function contribute(uint _campaignID){
    Campaign c = campaigns[_campaignID];
    uint256 amount = msg.value;
    c.balanceOf[msg.sender] = amount;
    c.amountRaised += amount;
    check = 'check4';
    token.transfer(msg.sender,amount/c.tokenValue);
    check = 'check5';
    FundTransfer(msg.sender, amount, true);      //event
}

Variable check is used for testing purpose. Even check variable is not updated. It is working fine in solidity browser. I am using geth client. Please tell me where i am wrong?


texts: How to better design pre sale and sale staged smart contracts

texts:
I am planning to create a stage based smart contract, like a pre-sale contract and then first and second stage of sales. What is best idea to do? Shall we create everything in one contract or multiple contracts for each stage would be a good practice.

If some one provide a code sample link, I'd appreciate that.

Many Thanks,


texts: Why do crypto-currency ventures pivot towards serving banks and what is Ethereum's approach?

texts:
I am new to the world of blockchains. I worked briefly for a blockchain venture until they started working with banks. Not a judgement call, I am simply more drawn to crypto-currencies as a fuel for micro-economies rather than a tool to lower banks' operational costs. Today I visited Ripple's website, which seems to be the 3rd largest crypto-currency, and I saw it is very bank-oriented.

I wonder what makes blockchain ventures pivot to the banking industry? Is it only the fact that banks have a need for security which gives early stage ventures a clear financial path? Does the difficulty to ignite the masses' enthusiasm regarding decentralized asset systems play a role?

Regarding Ethereum, between serving the financial industry and bringing blockchain to the masses, does the Ethereum project have any stated desirable path or is it non opinionated?


texts:
I'm running testrpc 3.0.5 locally on port 8454
Using Metamask 3.6.5

When I restart testrcp (and redeploy my contract) then my dapp still returns old values with Metamask. Without Metamask it works fine.

My current workaround is to connect Metamask to an other network then reconnect to localhost.

Is it some kind of caching by Metamask?

The workaround I'm doing is a bit time consuming when testing my Dapp. Is there a better way?


texts: Parser Error On Remix Solidity ERC20 Smart Contract Token

texts:
This Is My First ERC20 Smart Contract Token. I Am Trying To Compile It Using Solidity 0.5.0. Plz Need Your Help Guys.

pragma solidity ^0.5.0;

    contract TusharCoin {

  uint256 public totalSupply;
  string public name;
  string public symbol;
  uint32 public decimals;

    constructor () public {
  symbol  = "TUSHAR";
  name = "TusharCoin";
  decimals = 5;
  totalSupply = 100000000000;
    }

    constructor() public {
  owner = msg.sender;
  balances[msg.sender] = totalSupply;
    }
    emit Transfer(0x0, msg.sender, totalSupply);
 }

Error- Function, Variable, Struct Or Modifier Declaration Expected.

emit Transfer(0x0, msg.sender, totalSupply);
^--^


texts: Deploying a Contract at Test Time with truffle

texts:
I'm having trouble getting my test harness set up in truffle.  I have 2 contracts.  The first is an Issuing authority and in order for the second to be deployed, the creation address must be registered with the first.  I'm having a hard time figuring out how to best do this with truffle testing because I can't deploy the contract without it failing in my migration because the contract creation code throws(as expected).

I tried the below in my migration code, but the 'here i am' comment never gets hit.  I'm thinking it is because I don't really have a good space to do this in and it would be for moot anyway since each test creates its own little sand box.

var IssuingAuthority = artifacts.require("./IssuingAuthority.sol");
var CitizenAccount = artifacts.require("./CitizenAccount.sol");

module.exports = function(deployer) {
  console.log('about to deploy')
  deployer.deploy(IssuingAuthority).then(function(){
    console.log('about to deplyoy 2');
    IssuingAuthority.deployed().then(function(instance){
      console.log('about to call add citizen');
      instance.addCitizen.call(accounts[1]).then( function(result){
        console.log('here i am');
        console.log(result);
        deployer.link(IssuingAuthority, CitizenAccount);
        console.log(IssuingAuthority.address);
        deployer.deploy(CitizenAccount,IssuingAuthority.address);
      });

    });
  });
}

I'm wondering if I can get access to the deployer inside of a test so that I can deploy my contract to the network at test time.  something like this:

  var IssuingAuthority = artifacts.require("./IssuingAuthority.sol");
  var CitizenAccount = artifacts.require("./CitizenAccount.sol");

  contract('CitizenAccount', function(accounts) {
    it("should be authorized", function() {

      var ia = null;
      return IssuingAuthority.deployed().then(function(instance) {
        ia = instance;
        return instance.addCitizen.call(accounts[1]);
      }).then(function(result) {
        assert.equal(result, true, "citizen wasnt added");
      ///////////////////
      // I need to do a deployment here now that the issuer contract
      // has the address I want.
      /////////////////////////

        return CitizenAccount.deployed(ia.address);
      }).then(function(caInstance){

      });

    });

  });

Here is the code for my citizen account contract.  Feel free to point me to a better pattern if this just isn't going to work:

pragma solidity ^0.4.2;

import "./IssuingAuthority.sol";

contract CitizenAccount {
  address public issuingAuthority;
  address owner;

  function CitizenAccount(address _issuingAuthority) {
    IssuingAuthority i = IssuingAuthority(_issuingAuthority);
    bool isCitizen = i.isCitizen(msg.sender);
    if(isCitizen){
      issuingAuthority = _issuingAuthority;
    }
    else{
      throw;
    }
  }

}


texts:
Can anyone explain the above pics?

I sent 98,200 tokens.
It was successful.
But my qty and the receivers qty are doubled.

Please Help!!??!!


texts:
Does someone know what the .encodeABI() means on this the below line of code please?:
const data = electionContract.methods.vote(1).encodeABI()
Thank you
Take care
Pierre


texts: Privacy of smart contract? How can one implement "private" smart contract on Ethereum?

texts:
Based on my current reading, I understand smart contract as a code visible and runnable on the whole blockchain. The smart contract code could be published by author, and everyone can verify the code against the opcode in the contract address.

But how if someone wants to have privacy over their smart contract? How if they want to hide their detail implementation(to avoid hacker attack etc) while they want everyone to access and use their contract at the same time.

How to achieve private smart contract then?


texts: How block are validated in a private blockchain

texts:
I have running a private blockchain with 4 nodes, and when i'm creating my Dapp, i have specified for the web3 address only one node ( Ip; port, RCP)

So, my question is , how the others nodes participate in validating the block?  how they can make their own condidate block ?


texts: Copy and deploy a smart contract from opcodes without source code

texts:
I extracted opcodes from an already existing and deployed smart contract and I would like to know if it is possible to deploy an exact copy of this contract from its opcodes?
My extracted opcodes looks like this :
0x0, push1, 0x80
0x2, push1, 0x40
0x4, mstore,
0x5, push1, 0x4
0x7, calldatasize,
0x8, lt,
0x9, push2, 0x7f
0xc, jumpi,
0xd, push1, 0x0
0xf, calldataload,
0x10, push1, 0xe0
0x12, shr,
0x13, dup1,
...

I'm not looking for an alternative (e.g. deploying from bytecode or reverse engineering to source code) but really to deploy from these opcodes. Is that even possible? Or the lowest level possible is inline assembly with Yul?
I'm assuming there is no constructor in the source code. If I manage to deploy this code and send to it the right data (functions and parameters, let's say I have the ABI), will it behave exactly like the already deployed contract I got these opcodes from?
Thanks


texts: Is The DAO voting right proportional to the account tokens balance?

texts: Will I have more power on decisions if my token balance is high, or do I always have one vote whatever my balance is?


texts: .new isn't a function when deploying contract (web3)

texts:
I'm trying to deploy contracts using Ganache but I'm getting the following error.

I have my ABI and contract address defined, all other functions with respect to interacting with the contract work, however I cannot create a new one. Any ideas? Thanks.

The code is below...

newContract: function(error, result) {
  createContract.new(quantity,name,decimals,symbol,{from:account,gas:21000}).then(function(instance) {

  if (!instance.address) {
    console.log("Contract at: " + instance.transactionHash + " waiting to be mined");

  } else {
    console.log("Contract mined. Here it is: " + instance.address);
    console.log(contract);
  }

  console.log(instance.address);
});

This is the error -

  TypeError: createContract.new is not a function

Update:
It is initialized via

var createContract = web3.eth.contract(createContractabi);

I'm wondering if the error is being generated as my currentprovider is giving an error...

Both createContract.setProvider(this.web3.currentProvider); and createContract.setProvider(web3.currentProvider); were tried.

However, both fail, with the errors

  TypeError: Cannot read property 'currentProvider' of undefined

and

  TypeError: createContract.setProvider is not a function

respectively.


texts: Does ERC-20 or ERC-721 compliance mean anything of consequence? Are these standards necessary to use

texts: Why do we have to use these standards? Is complying with these standards a necessity if we want our token to be listed anywhere? If our token doesn't fit within the listed standard, can we still have our token be "valid"?


texts: Shall I just ignore if safeTransfer failed?

texts:
I googled and found that we shall use the following code to avoid paying too much to a contract recursively or consumed too much gas fee in one single transaciton.

function safeTransfer(address payable _base, uint value) internal {
    (bool success, ) = _base.call.value(value)("");
    require(success, "SafeTransfer");
}

In my use case, I am paying to 10 persons in one call.

I am wondering shall I just ignore if success=false. Because if the recipient is hostile, there is no reason for me to fail my entire transaction just because of him.


texts: Update dapp after contract transaction is mined

texts:
I made a web app that interacts with a smart contract, using truffle unbox webpack. My contract has a variable called sum and 2 functions: one called answer that increments the sum variable after it is executed and an onether fuction called total that returns the value of the variable sum. In my app.js i have the code:

SmartContract.deployed().then(function(contractInstance) {

contractInstance.answer(1, {gas: 140000, from: web3.eth.accounts[0]}).then(function(v) {
    return contractInstance.total.call().then(function(total){
                                    $("#total").html(total.toString());
            });
});

}

My question is whether the call contractInstansce.total will be executed after the transaction call contractInstance.answer is mined, so that the variable total in my index.html will have the updated value.Also is the word "return" necessary after a transaction call function ,like answer in this example, in order the following contract call function, like total in this example,to be executed after the transaction is mined?

I used testrpc to test if my web app is working as expected, but in testrpc the blocks are mined instantly, so i am not sure if the code i wrote will be correct if i use this application in testnet network.Thanks a lot for your time!


texts: What does "RlpInvalidIndirection" error mean?

texts:
I run my own Parity node for Ropsten network.

I am sending raw transactions to the node with "eth_sendRawTransaction" api, and sometimes it returns {-32602, "Invalid RLP.", "RlpInvalidIndirection"} message. It occurs occasionally(once in 20 times? approximately).

As I googled, I get to the parity source code page(link). However, I can't get more useful information about it. There's just a comment below on it.

/// Non-canonical (longer than necessary) representation used for data or list..

Since most of times it succeeds, it doesn't make sense for me. Lengths of all the messages are same.

What does that message generally mean?

I am sorry that I can't attach the full source code of mine because of a personal reason.


texts: How to trace state of transactions in ethereum

texts:
I have a smart contract of Student Registration. The state changes in the following manner:

When Student enters the credential in the form, the state is OPEN.
When college registers the student against its credentials, state is REGISTERED.
When payment of fee is done, state becomes PAID.

Here, after every action, i.e registration or payment, i receive a transaction hash of the transaction. How can i trace all the states of this process with transaction hash only. This is also called as Audit trail. How can i accomplish this in solidity or ethereum?


texts: Estimating gas costs for large batch of transactions

texts:
I noticed on EthGasStation the following below the estimated gas prices:

  Note: Estimates not valid when multiple transactions are batched from the same address or for transactions sent to addresses with many (e.g. > 100) pending transactions

How are the estimates affected by having multiple transactions batched from the same address or to addresses with many pending transactions?  What parts of the estimate are invalid, in which direction (high/low/unknown), and why?

What is a good way to estimate the costs associated with a batch of e.g. >100 transactions?

(Also, is "batch" a technical term with specific meaning as applied to Ethereum transactions, or does this word carry just the common meaning, "a group or set, issued relatively close in time to each other"?)


texts: Everyone is asking Now is Ethereum still ASIC Resistant?

texts:
According to Bitmain - plus other 3 company in china, that they will lunch Asic Miner Machine for Ethereum this 2nd Quarter 2018.

My question is there any way that ethereum can prevent this to happen?

Is this news true?

How Resistant Ethereum from Asic Miner Machine?


texts: Solidity | fixed data type of variable for transferring custom token (erc20)

texts:
I'm using simple transfer function like below.

  function _transfer(address _from, address _to, uint256 _value) internal {
    balances[_from] = balances[_from].sub(_value); // Subtract from the sender
        balances[_to] = balances[_to].add(_value); // Add the same to the recipient
    Transfer(_from, _to, _value);
}

The token amount of argument is received as uint256 data type so that I can't transfer the custom token as float data type even I deployed my token as 18 Decimals. For example, I want to transfer the amount of token like 0.00001, 0.00000002. I noticed the ufixed data type currently on Solidity 0.4.21 but I can't test on Remix with 0.4.21 version and fixed type. How can I transfer my token with ufixed data type?


texts:
love parity, great Ethereum Client and a stunning pace of progress. If the developers read this: Much thanks!

But there is one little tiny bug ... When I start parity and open the visual wallet in the browser, everything's fine. My balance are shown, my token are shown. But something like five minutes later the token disappear. I still see the accounts they are on, but not the token. Like as Parity lost contract wit


texts: Is it possible to revoke file access with Swarm?

texts:
A file must be uploaded to a decentralized storage network since it is too big for the blockchain.

Only selected entities must be able to access it. Looking at the Swarm documentation, it says that the file author can grant permission to his file.

However, is it also possible to revoke that permission?


texts:
I've a smart contract under test, which exposes a public property of type address bestSeller:

contract Club {
    address public owner;
    uint public price; //price to join the Club
    uint public membersCount;
    uint public bestSale; //the best sale till now
    address public bestSeller; //the user who presented more users

so now I reduced my test to the minimum necessary to reproduce the problem, and it looks like:

it("report correctly the best seller"),async () => {

  let bestSeller =  await instance.bestSeller.call();
 })

all the test works, except this one that remain in "pending", as reported by truffle test:

What can be the problem?


texts:
I want to distinguish between contract addresses and smart contract addresses. But when running

web3.eth.getCode()

in the geth console with either a contract or a non-contract address, it returns "0x".

I am using geth 1.8.22. Does anyone has an idea why that happens?


texts: How to know when geth --rpc is finished so i can start mining

texts:
i have Geth --rpc running but it seems that it is never-ending.

Do I have to wait for Geth to stop before i use ethminer?

thsnks for helping.


texts: What tools are available or being developed for cross-chain operations?

texts: Are there any headways being made for BTC, ETH, other blockchains cross-talk?


texts:
I am using the openzeppelin library and importing the StandardBurnableToken.sol logic into MyContract.sol

here is a code

pragma solidity ^0.4.17;

import "/openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol";
import "/openzeppelin-solidity/contracts/token/ERC20/StandardBurnableToken.sol";

 contract MyToken is StandardToken {
  string public name = 'Membership Token';
  string public symbol = 'MTKO';
  uint8 public decimal = 18;
  uint public INITIAL_SUPPLY = 1000000;

 constructor() public {
  totalSupply_ = INITIAL_SUPPLY;
  balances[msg.sender] = INITIAL_SUPPLY;
 }
}

Do I need to add another function in MyToken.sol to be able to call the burnFrom() function? or is that once the logic is in the ABI it can send tokens to 0x0 addresses?


texts:
I'm pretty new to mining, but I hope someone can help me.

when I use eth.syncing, I get this result:

 currentBlock: 1,
 highestBlock: 4884563,
 knownStates: 42878500,
 pulledStates: 42868030,
 StartingBlock: 4882867
}

Am I mining correctly?

When I type web3.fromwei(eth.getBalance(eth.coinbase), "ether"),
it says:

5

But when I enter MEW with the key, there is not 5 ether in there?


texts:
Trying to connect Ganache GUI running on port 7545 to web3.js. Getting the below error whenever trying to call any of the functions of web3 -
> web3.eth.getBalance("0x907A41F173099E5F5573F0ab43B6Dd9594e3687a").then(console.log);
Promise { <pending> }
> Uncaught Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (/mnt/c/.../web3_development/node_modules/web3-core-helpers/lib/errors.js:43:16)
    at XMLHttpRequest.request.onreadystatechange (/mnt/c/.../web3_development/node_modules/web3-providers-http/lib/index.js:95:32)
    at XMLHttpRequestEventTarget.dispatchEvent (/mnt/c/.../web3_development/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/mnt/c/Users/.../web3_development/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpRequestError (/mnt/c/.../web3_development/node_modules/xhr2-cookies/dist/xml-http-request.js:349:14)

Running node on WSL-2.
Any help as to what might be causing the issue or ways to resolve it would be really helpful.
Thanks a lot!!


texts: How to extract int128 from msg.data as first argument?

texts:
Let's say we have Ethereum smart contract with fallback function:

event onDeposit(int128 indexed key, address from, uint amount);
...
function () payable public {
  require(msg.value > 0);

  int128 key = ... // how to extract it from msg.data? (0x123)
  address from = msg.sender;
  uint amount = msg.value;

  // fire event
  emit onDeposit(key, from, amount);
}

and taking into account key is entered in myetherwallet.com like that:

Is it correct that i should skip 4 first bytes in msg.data (function address) and get the next 4 bytes (int128 size)? How can i do it (slice bytes and cast them as int128)?


texts:
I am working on a private test net. I have deployed a contract using Ethereum wallet. And in the contract I have a function to transfer coins from one account to other.

function transfer(address _to, uint256 _value) {
    if (balanceOf[msg.sender] < _value) throw;           // Check if the sender has enough
    if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
    balanceOf[msg.sender] -= _value;                     // Subtract from the sender
    balanceOf[_to] += _value;                            // Add the same to the recipient
    Transfer(msg.sender, _to, _value);                   // Notify anyone listening that this transfer took place
}

I am able to transfer coins using Ethereum wallet but didn't know how to do the same using geth console.

Then I came accross eth.contract(ABI).at(Address);

which was a solution to my problem. But while using:

var cont=eth.contract(ABI).at(Address);
cont.transfer("0x506B2FAcCC8fF7f1F9633491985E0b997c6F5Fc7", 100)

I am getting errors:

invalid address
at web3.js:3887:15
at web3.js:3713:20
at web3.js:4939:28
at web3.js:4938:12
at web3.js:4964:18
at web3.js:4989:23
at web3.js:4055:16
at web3.js:4141:16
at <anonymous>:1:1.

I am beginner to Ethereum. Don't know even if I am going right?


texts: How to build a blind voting contract in Solidity

texts:
Can we build a smart contract where it is not possible to see the actual vote until the voting period ends? One idea is to use hashing. Voters can send a hashed version of a vote. The problem with voting is that there is only two options, but we can add something like salt together to circumvent this. And then after the end of the voting period, the voters have to reveal their votes. They send their values unencrypted and contract checks that the hash value is the same as the one provided during the voting period.

The problem is that there is one extra step for voters, and thus it is not usable.

Any ideas?


texts: How can I recover the path to a specific transaction in the tx patricia merkle tree?

texts:
I'm working on a project where a non trusted entity is running an ethereum node (either geth or aleth), and has to pass information along to a non networked party. Namely, the non networked party needs to check if a tx was included in a mined block. For this, I need:

The block header of the block containing the tx (from which I can verify difficulty). This is trivial.
Either the entire tx tree, or just the relevant nodes in the tx tree (with which I can verify inclusion).

For the second part, it does not seem like I can retrieve this via a JSON-RPC call. It seems like I cannot interact with the leveldb files directly because doing so would preclude me from running a node, as both aleth and geth seem to grab the ldb lock and hold on to it. This means that I can't just run a node server with merkle-patricia-tree. Is there some other obvious way to do this that I'm missing? Or is the only solution to roll my own aleth/geth node that exposes this functionality?


texts: Can I retrieve data from smart contract to my local webpage without using metamask?

texts:
I am creating a DApp where I want to show the public variable's information from the contract. I want my users who don't have metamask to see this information also.
Is there a way I can do that?

If I use the DApp without using metamask then it returns that 'web3' is not defined.

Here is my code snippet of app.js when page loads [throws error at line 3]:

$(document).ready(function() {
// Ropsten:
var contractAddress = "0x208122Dc624EF89fD1960B060775439494FAa9ab";

var version = web3.version; // throws error at this line.
console.log(version);
// Modern dapp browsers...
if (window.ethereum) {
    window.web3 = new Web3(ethereum);
    try {
        // Request account access if needed
        ethereum.enable();
    } catch (error) {
        // User denied account access...
        console.log(error);
    }
}
// Legacy dapp browsers...
else if (window.web3) {
    window.web3 = new Web3(web3.currentProvider);
}
// Non-dapp browsers...
else {
    console.log('Non-Ethereum browser detected. You should consider trying MetaMask!');
}

window.ethereum.on('accountsChanged', function(accounts) {
    updateDetails(accounts[0]);

});

Contract = new web3.eth.Contract(abi, contractAddress);
console.log(Contract);
});

Error:

Uncaught ReferenceError: web3 is not defined
    at HTMLDocument. (app.js:6)
    at i (jquery-2.2.4.min.js:2)
    at Object.fireWith [as resolveWith] (jquery-2.2.4.min.js:2)
    at Function.ready (jquery-2.2.4.min.js:2)
    at HTMLDocument.J (jquery-2.2.4.min.js:2)


texts: Is there a way to logout of MetaMask from my own frontend, allowing the user to logout with a button rather going up to the Metamask extension and logging out through the traditional manner?


texts: Is it possible for a smart contract to be able to adjust it's conditions based on the current value of Ethereum?

texts:
I ask this because I want to create a crowdfunding smart contract for a platform much like Kickstarter. At this point, the only crypto asset I want the contract to raise is Ether with the possibility of integrating other ERC20 tokens in the future. The issue I am trying to overcome right now is price volatility. For example, if a client wants to raise £10,000 worth of ETH during the 30 day period of crowdfunding and on the day of listing the project, the value of Ether is £100 each, then 100 ETH is needed for the contract to be successful. However, if toward the end of the crowdfunding duration, the price of Ether drops by 20%, then the client would only get £8,000 worth of Ether. Another issue is if the price goes up dramatically before the end of the project, potentially setting the milestone too high and sabotaging the project.

I would like a way for the contract to be updated every 5 minutes or so based on the current price of Ether to tackle the problem of volatility. So for example, if the price goes up by 20%, then each ETH will be worth £120 and that multiplied by 100 is £12,000 which may be too much. When this occurs, it would be ideal if the contract could somehow be updated and adjust the target goal based on some simple calculations (target goal in GBP / 1 ETH to GBP = target goal in ETH). I want to implement such a feature in order to add some stability to the target goal in ETH in relation to GBP (or other fiat currencies).

I have seen similar implementations that can update contracts based on the value of other crypto assets, such as: Oracilize, which is capable of checking the price of Kraken, but nothing that does so with fiat currency.


texts: When calling a contract from an other contract, what happends if the value of callgas argument is above availaible gas?

texts:
In such case, the value is replaced with available gas right ?
Or Does an out of gas exception is thrown ?


texts: Returned error: insufficient funds for gas * price + value in Private network

texts:
I created private network and mined some ether, when I was try to send some ether to another account in my private network I am getting "Error: Returned error: insufficient funds for gas * price + value - Private network" error.

Genesis.json

{
   "config": {
     "chainId": 4545,
     "homesteadBlock": 0,
     "eip155Block": 0,
     "eip158Block": 0
},
"alloc" : {},
"coinbase" : "0x75bcb134477f42f6fefbf177f9a610c0665e23a6",
"difficulty" : "0x20000",
"extraData" : "",
"gasLimit" : "0x2fefd8ffffffffff",
 "nonce" : "0x0000000000000042",
 "mixhash" :
"0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" :
"0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}


texts: Which one is suitable frameworks for Dapp development(Truffle, Embark, Dapple)?

texts:
Right now we have major Dapp development frameworks.

Truffle Framework
Embark
Dapple

What are the pros and cons of each one. On what basis this could be chosen.

And what each frameworks needs to make more developer friendly?


texts:
I have the follow use case:
There is an off-chain service, like a game, which will generate/mint new ERC20 tokens when some requirements are met by end-users. Since the users will get profit (in terms of ERC20 tokens), I do not want to pay the transaction fee of calling the mint function in the ERC20 contract.
Question: How can I make users pay the transaction fee of mint while under the control of my off-chain service (e.g. not violating the rule of minting new tokens)?
I know usually, this gas-paid-by-someone-else use case is often something like: the user do not need to pay the transaction fee, while a third-party will pay the fee. And there are a lot of mature libraries can do this, like openzeppelin GSN. But in my case, this is different.
I found a related question here talking about the general solution to such problems. But I prefer not to implement too many things by myself, since there may be security issues. Are there any libraries that can help me achieve my goal?
Thanks in advance.


texts: Trigger manual DB UPSERTs through smart contract

texts: Can I add a trigger to smart contract to insert/update data to my traditional DB. E.g. Let's say I have students private blockchain where each student has to update their info. Once they insert/update it, I am maintaining a database with all the current information as I do not want to change my legacy app that is built on traditional DB. I understand that every time the students update their info, it will cost the ether and I am ready for that. In other words, can I have callbacks once a method gets executed on smart contract so I can continue performing actions from my server.


texts:
I'm interested in how does the process "geth" (in a full node) work. I mean in which components can the geth conceptually be split.

In my understanding there should be at least (conceptually) three components:

One component should keep the connection with the other peers (to maintain the p2p network)
One component should process the blockchain and check the validity of the information (execute smart contracts and so on)
One component should listen to incoming RPC calls and responds accordingly

Can we identify other components?


texts: Importing other contracts into one another

texts:
I want to know What is the differences between :

1) import './OtherContract.sol'

2)  contract cont is OtherContract {}

3)in truffle's migration.js : deployer.link(cont,OtherContract)

i know they serve to make some relationships between contracts, but i can't figure out the differences


texts: Transaction with multiple contract "send" requests

texts:
Recently we were trying to create an application that allows the user to buy an NFT using an ERC-20 token (let's say for these purposes it's a stablecoin like DAI or USDC). So from figuring everything out we
  public async approve(): Promise<void> {
    const ticketPrice = 100;

    // Approve the contract to transfer on your behalf
    const contract = new this.web3js.eth.Contract(TestUSDContract.abi, this.USD_ADDRESS);
    const success = await contract.methods.approve('<CONTRACT ADDRESS>', ticketPrice).send({from: '<USER ADDRESS>'});
    console.log('Status ' + success);

    //Then purchase the item the user wants
    const contract2 = new this.web3js.eth.Contract(LotteryContract.abi, this.CONTRACT_ADDRESS);
    const value = await contract2.methods.buyItem().send({from: '<USER ADDRESS>'});
    console.log('contract2 ' + value);
  }

For transparency, the following is the contract method used for testing
  function buyTicket() external returns (string memory) {
    testUsdContract.transferFrom(msg.sender, address(this), itemAmount);
    return "SUCCESS";
  }

This all works, however, from a UX perspective, the user gets two dialogs from the UI which seems like bad UX.
Also from what I understand (and makes sense) the approve method MUST be called from the user's account (and cannot be from the contract as msg.sender on the ERC-20 token will be our contract).

I was wondering what workarounds exists for this AND how other apps accomplish accept ERC-20 items as payment (in a user-friendly manner preferably).

This also begs the question, what happens when the first request is successful and the second fails (could be of network error, or a contract exception), how would one handle that usually in a DAPP (and how have other dapps done this?)


texts: Bitcoin mining vs Ethereum mining, How does it differ?

texts: I have understood how Bitcoin mining is done and what exactly the miner solves during the mining process and adding a new block on bitcoin blockchain, I failed to get any information on what ethereum miners have to solve in order to mine ether and create a new block to be added to ethereum blockchain, please share a link or details if possible


texts: How to enable constructors in the new REMIX IDE or Truffle framework since MIST is depreciated

texts:
I used to dabble with making tokens and contracts and started to get back into it.
I liked the functionality that mist offered where you could input constructors values directly in mist. I can not seem to find a way to do this with remix IDE? How do I enable this option in Remix compiler or a maybe use a different development framework? What wallet are people using to compile and test code since MIST is no longer supported?
I used to just add my unsigned integers and then input the arguments later.


texts: why can't we get the meta mask injected account using web3.py?

texts:
I am trying to get the current account from meta mask in my Dapp ,i am using web3.py.
In web3.js ,web3.eth.getCoinbase() returns the current account of the metamask, but web3.eth.coinbasein web3.py is returning the default address.
how do we get the current metamask account in web3.py?


texts:
Can you guys please help me to understand how does a contract temporarily keeps a funds inside itself? I am looking the Solidity docs and tutorials and I see, that it is possible to keep a funds inside a contract for some time and then to send these funds to owner using the suicide() method.

I refer to this tutorial. According to the code example, the contract looks like this:

contract Conference {

   address public organizer;
   mapping (address => uint) public registrantsPaid;
   uint public numRegistrants;

   // ...

   function buyTicket() public returns (bool success) {
     if (numRegistrants >= quota) {
         return false;
     }
     else {
         registrantsPaid[msg.sender] = msg.value;
         numRegistrants++;
         return true;
     }
   }

   // ...

  function destroy() { // so funds not locked in contract forever
     if (msg.sender == organizer) {
        suicide(organizer); // send funds to organizer
     }
  }
}

As far as I understand from this example, the function buyTicket() should take some funds from a user calling this transaction and persist it somehow inside a blockchain as a stored data. But I don't see any payments here, I can only see that we put user's value and address inside the internal mapping, such as registrantsPaid[msg.sender] = msg.value;.

Can you please explain to me, what exactly happens in the function buyTicket()? How does the suicide(organizer) knows where all funds are stored inside a contract? Is there actual money are transferred form user to a contract inside the buyTicket() function? Where exactly the destroy() is calling?

Thank you very much. Sorry, for noobish question :/


texts: If I copy a SmartContract bytecode and deploy it with a different account on my private testnet, will it retain the same functionality? Assuming that owner address isn't hardcoded, will I be able to send identical calls from my local account and get the same results? I am looking to reverse engineer some contracts that don't provide ABI and use obfuscated input data.


texts: Solidity 0.6.0 and address(f) to f.address

texts:
I was struck by this Solidity 0.6.0 breaking change:

  Change address(f) to f.address for f being of external function type.

Not a big deal, but I'm clearly very ignorant here. 2 stupid questions. Q1: I use

contractAddress.f()

a lot, where 'contractAddress' is the contract's Ethereum address, and f is some external function in that contract. Does this imply I should change my code to write

f.contractAddress()

instead? Q2: Does this mean I should change

address(this)

to

this.address

?


texts: What are GavCoins and what is their significance?

texts: Quite simply, what are GavCoins and what is their significance?


texts:
The normal operation of Ethereum and other blockchains is to Store new transactions in a mempool, Distribute the bucket, and then mine contents into a block picked from the bucket based on priority of the Gas fee and execution time to fire within the 15 Seconds execution window.
The big Question I am find difficulty answering after long search and much reading is what method does the Chain use to Synchronise those Buckets?
Does anyone have a flow chart, Description or link to an article that explains the mechanism.
Some problems come to mind that I don't have clarity on how its solved, for example. When a node receives a new transaction, what is the logic for it to be transmitted around the network? is it a Pull Push, Transmit or other Synch method, that handles out of sync issues, such as keeping track of what transactions have already been synched to its neighbor.


texts: Unique Constraint NFT, only 1 allowed per Address?

texts:
Is it possible to program an NFT to only allow 1 copy of it per address?
For example if Address #1 and #2 both already have 1 copy of this NFT, if Address #1 tries to send theirs to Address #2, it should fail to send.
Would this involve overriding the default behavior of "transferFrom" ERC721?
Any suggestions on where to look on how to make this work?


texts: Can any information beside the address be encoded into QR code?

texts:
I want to create a contract.
I want to generate a QR code to invoke this contract.
I want to present this QR code to a user.

Is there a way to embed any additional information into the QR code (like username or seed or any other small piece of data)? In other words, I want to pass some values into contract by encoding it into QR code. Each generated QR code would look different, but invoke the same contract.

Thank you!


texts:
I recently read about Tendermint releasing it's own public blockchain soon.

After crossreading their blog, I see multiple mentions of the EVM.

Does Tendermint implement the Ethereum Virtual Machine? Will Ethereum Smart Contracts also work on Tendermint?


texts: Is it possible to instantiate a deployed contract in js using contract address alone? without copying abi data?

texts: Is it possible to instantiate a deployed contract in js(dapp) using contract address alone? without copying abi data?


texts:
Can anyone give me a straight answer, (not trained stranded in no man lands) do I just change the words from (functions to Constructor) yellow warnings below.

browser/ballot.sol:77:5: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
    function Owned() public {
    ^ (Relevant source part starts here and spans across multiple lines).

browser/ballot.sol:118:5: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
    function ?name?Token() public {
    ^ (Relevant source part starts here and spans across multiple lines).

browser/ballot.sol:91:9: Warning: Invoking events without "emit" prefix is deprecated.
        OwnershipTransferred(owner, newOwner);

        ^-----------------------------------^
browser/ballot.sol:152:9: Warning: Invoking events without "emit" prefix is deprecated.
        Transfer(msg.sender, to, tokens);
        ^------------------------------^
browser/ballot.sol:167:9: Warning: Invoking events without "emit" prefix is deprecated.
        Approval(msg.sender, spender, tokens);
        ^-----------------------------------^
browser/ballot.sol:185:9: Warning: Invoking events without "emit" prefix is deprecated.
        Transfer(from, to, tokens);
        ^------------------------^
browser/ballot.sol:206:9: Warning: Invoking events without "emit" prefix is deprecated.
        Approval(msg.sender, spender, tokens);
        ^-----------------------------------^
browser/ballot.sol:224:9: Warning: Invoking events without "emit" prefix is deprecated.
        Transfer(address(0), msg.sender, tokens);
        ^--------------------------------------^


texts: What's the Purpose of the Vertical Rule Dividing the Work-Space in Browser-Solidity?

texts: And can it be eliminated? I find it distracting.


texts: Uniswap V2's swapExactETHForTokens: How to know the number of tokens bought

texts:
I wrote the solidity function below to swap ether for other tokens on a Uniswap exchange. It works.
function buyCryptoOnUniswap1(uint256 etherCost , address cryptoToken) public payable returns (uint256) {

  IUniswapV2Router02 usi = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);

   if(etherCost > address(this).balance){
          return 0;
    }
    uint deadline = now + 300; // using 'now' for convenience, for mainnet pass deadline from frontend!

    uint[] memory amounts = usi.swapExactETHForTokens.value(etherCost)(0, getPathForETHToToken(cryptoToken), address(this), deadline);
    uint256 outputTokenCount = uint256(amounts[1]);

    return outputTokenCount;
      }

  function getPathForETHToToken(address crypto) private view returns (address[] memory) {

    address[] memory path = new address[](2);
    path[0] = usi.WETH();
    path[1] = crypto;

    return path;
  }

According to the docs, the returned value called amounts is an array of uints which consists of the input token amount and all subsequent output token amounts.
amounts,  uint[] memory,  The input token amount and all subsequent output token amounts.
So I hazarded a guess as to it(the number of purchased tokens) been in index 1 of the return value.
Please how do I get the number of tokens returned by this transaction?
Sorry, but it doesn't seem so clear from the documentation..
Thanks


texts: Cannot "npm install -g truffle-expect truffle-config web3"?

texts:
I'm trying to setup development environment of truffle but I got the following error when running npm install -g truffle-expect truffle-config web3 on Windows 10 enterprise N on Azure.

PS C:\Windows\system32> npm install -g truffle-expect truffle-config web3

> web3@1.0.0-beta.4 postinstall C:\Users\wanxxx\AppData\Roaming\npm\node_modules\web3
> lerna bootstrap

'lerna' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\wanxxx\AppData\Roaming\npm
+-- truffle-config@1.0.1
`-- truffle-expect@0.0.3

npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "ins
tall" "-g" "truffle-expect" "truffle-config" "web3"
npm ERR! node v6.11.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! web3@1.0.0-beta.4 postinstall: `lerna bootstrap`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the web3@1.0.0-beta.4 postinstall script 'lerna bootstrap'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the web3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     lerna bootstrap
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs web3
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls web3
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Windows\system32\npm-debug.log

How to resolve the issue? I can install everything on Windows 10 professional on my laptop.


texts: A solidity function to accept two mappings and return a single combined map

texts:
I've been attempting to implement a function to combine two mappings into a single one:

contract Mappulator {
    mapping(address => int256) public BigMap;
    struct mapper { mapping (address => int256) map;}

    function MappingCombiner(mapper map1, mapper map2){
        BigMap = map1.map + map2.map;
    }
}

According to this I must wrap the mappings in structs to be able to pass them to a function. With the above code I get the following error:

Internal type is not allowed for public or external functions.
function MappingCombiner(mapper map1, mapper map2){
                         ^---------^

If I add the storage keyword, as suggested here, I get:

Location has to be memory for publicly visible functions (remove the "storage" keyword).
function MappingCombiner(mapper storage map1, mapper storage map2){
                         ^-----------------^

The compiler is not getting as far as BigMap = map1.map + map2.map; for me to assess if that is valid. I'm assuming not because, to combine them, both maps would have to be iterated over, which is not straight-forward. Also, it doesn't look like any operator is defined to do this.

Where am I going wrong here? Would I be better off defining/converting to arrays?

Can any provide/point to a working example of mappings being passed to a funtion and combined?


texts: how to send a payment transaction using web3js... and fetch contract address dynamically using web3js without hardcoding in app.js

texts:
function sendPayment(uint orderNumber) public payable{
   //restricting only buyer of partitcular order can make payments
   require(Orders[orderNumber].buyerAddress==msg.sender);

    //checking whether amount=totalPrice
    require(Orders[orderNumber].totalPrice==msg.value);

}


texts: How can I measure a function execution time based on Truffle?

texts:
I'm using truffle to test my smart contract written in solidity language deployed on the Quorum blockchain.
I want to measure the execution time of the invocation of a function using truffle.
Is that possible in the truffle commande line?
Otherwise, is there any proposition for a solution to measure the execution time of a function in a smart contract whatever how it was invocated?


texts:
Im trying to create a node.js based dapp that interacts with ropsten ethereum network via infura node.here we need sign transaction with web3.js. but the code showing error from the contract side. please let me know what seems to be the problem

let myData=contract.methods.greet("hello blockchain devs").encodeABI()
                            ^

TypeError: Cannot read property 'greet' of undefined

here is my code:

var Tx     = require('ethereumjs-tx')
const Web3 = require('web3')
const web3 = new Web3('https://ropsten.infura.io/<API KEY>')

const account1 = '<account address>' // Your account address 1

const privateKey1 = Buffer.from('<Private Key>', 'hex')
const abi=[{"constant":false,"inputs":[{"name":"_greeting","type":"string"}],"name":"greet","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getGreeting","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}];
const contract_Address="0xcbe74e21b070a979b9d6426b11e876d4cb618daf";
const contract =web3.eth.contract(abi, contract_Address)
let myData=contract.methods.greet("hello blockchain devs").encodeABI()
web3.eth.getTransactionCount(account1, (err, txCount) => {
  // Build the transaction
  const txObject = {
    nonce:    web3.utils.toHex(txCount),
    to:       contract_Address,
    value:    web3.utils.toHex(web3.utils.toWei('0.1', 'ether')),
    gasLimit: web3.utils.toHex(21000),
    gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei')),
    data: myData
  }

  // Sign the transaction
  const tx = new Tx(txObject)
  tx.sign(privateKey1)

  const serializedTx = tx.serialize()
  const raw = '0x' + serializedTx.toString('hex')

  // Broadcast the transaction
  web3.eth.sendSignedTransaction(raw, (err, txHash) => {
    console.log('txHash:', txHash)
    // Now go check etherscan to see the transaction!
  })
})


texts: How to catch a `revert()` error using Brownie?

texts:
I am using Brownie to develop my smart contracts, which helps me to intract with the smart contracts, please see doc.

When my call Example.greet() is there any way to return the error message and act based on it during my tests? Also find out is it reverted because the transaction is out of gas or not.

Similar question is answered for Truffle: [how to catch “revert” error in truffle test javascript?].

Example of a simple contract with a revert() message:

contract Example{
    function greet(){
        revert("Hello World");
    }
}


texts: i want to know how many miners can i have with 65kw provided by solar panels, the average of the miners is 1200w 100-250v 47-64Hz.


texts: Call contract function from truffle console

texts:
I want to call a fucntion of deployed contract not deployed by me (I have a contract address and ABI), is it possible to do from truffle console? There are a lot of examples how to do it using js, but not using truffle. If it's possible, could you please provide me few examples?

Thanks!!


texts: How to execute smart-contract functions on Ruby?

texts:
Is it possible to execute smart-contract functions using Ruby?
For example executing function mint on behalf of the smart-contract's owner?


texts: i am trying to send a signed transaction for my solidity code but i am encounting some error can anyone suggest me the fix?

texts:
pragma solidity^0.5.0;
import "./TokenSale.sol";
contract Dice{

    TokenSale public tokenSale;
    address tokensaleaddress;

    struct player_details{
        address pAddress;
        string pName;
         }

    struct gameRecords{
        address playerAddress;
        uint selected_num;
        uint rolled_num;
        bool result;
        uint ptoken;
        uint timestamp;
    }

    constructor (TokenSale _tokenSale) public {
      tokenSale = _tokenSale;
    }

    mapping(uint =>gameRecords) public outcome;
    mapping(uint => player_details) public details;

    uint public playerid=0;
    uint played=1;
    uint playercount=0;

      function setplayerDetails(string memory _pName) public{
        details[playerid] = player_details(msg.sender,_pName);
        playerid++;
        playercount++;
      }

    function addGameEvent(uint _betplaced, uint _rollresult,bool _result,uint _ptoken) public{
        require(playercount >=1 );
        outcome[played] = gameRecords(msg.sender,_betplaced,_rollresult,_result,_ptoken,now);
        played++;
    }

    function tokenfetch() public {
        // require (playercount >=1);
        tokenSale.buyTokens(100);
    }

  }

Here is my App.js raw transaction code

  const Web3 = require('web3');
  const web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/f072e47f51ae4419beecd1c3c16d0124"));
  const Tx = require('ethereumjs-tx');
  const provider = new Web3.providers.HttpProvider("http://localhost:8545");
  let account = this.owner_account;
  let nonce;
  web3.eth.getTransactionCount(account).then(_nonce => {
    nonce = _nonce.toString(16)
  });
  let myPrivateKey = this.owner_private_key;
  let privateKey = new ethereumjs.Buffer.Buffer(myPrivateKey, 'hex');
  const contract = new web3.eth.Contract(abi, CONTRACT_ADDRESS, {
  from: account,
  });
  let gasPrice = window.web3_.toHex(500000000000) // 500 Gwei
  let gasLimitHex = window.web3_.toHex(6000000)
  const functionAbi = contract.methods.myFunctionName(myArgument).encodeABI()
  let rawTx = {
    'nonce': nonce,
    'gasPrice': gasPrice,
    'gasLimit': gasLimitHex,
    'from': account,
    'to': this.to_contract_address,
    'data': data,
    'chainId': '0x03'
  }

  let tx = new Tx(rawTx);
  tx.sign(privateKey);
  tx.serialize();
  console.log(tx.validate());
  let serializedTx = '0x' + tx.serialize().toString('hex');
  console.log(serializedTx);


texts: Is it possible to have a mapping with a hash as key?

texts:
Is it possible to have a mapping in Solidity with a hash as key?

For example:

mapping (hash => uint) hashToInt;

If not, is there any way to group some information and put it as a key of a mapping?


texts: Why a buffer is required in the process of creating keys from the seed

texts:
This hdkey library is creating a Buffer in the process of creating keys as an example.

var HDKey = require('hdkey')
var seed = 'a0c42a9c3ac6abf2ba6a9946ae83af18f51bf1c9fa7dacc4c92513cc4dd015834341c775dcd4c0fac73547c5662d81a9e9361a0aac604a73a321bd9103bce8af'
var hdkey = HDKey.fromMasterSeed(Buffer.from(seed, 'hex'))

It looks like this is a common practice, but I don't understand why we need a buffer.

I was wondering what happens if I don't use it.

So I tried:

import HDKey from 'hdkey';

const seed =
'a0c42a9c3ac6abf2ba6a9946ae83af18f51bf1c9fa7dacc4c92513cc4dd015834341c775dcd4c0fac73547c5662d81a9e9361$
const hdkey = HDKey.fromMasterSeed(seed);
console.log("hdkey ===>", hdkey);

const hdkeyWithBuffer = HDKey.fromMasterSeed(Buffer.from(seed, 'hex'))
console.log("hdkeyWithBuffer ===>", hdkeyWithBuffer);

Then I get this:

$ npm run index.mjs

> testHdkey@1.0.0 index.mjs /Users/tai/Dropbox/Codes/testHdkey
> node --experimental-modules index.mjs

(node:25246) ExperimentalWarning: The ESM module loader is experimental.
hdkey ===> HDKey {
  versions: { private: 76066276, public: 76067358 },
  depth: 0,
  index: 0,
  _privateKey:
   <Buffer 5c 31 9c 7f 1b 0a ea 87 97 f7 94 80 12 ef bd 0d 11 58 43 fc 9a 12 34 01 c1 fc ba bc 3b d3 14 d1>,
  _publicKey:
   <Buffer 02 55 73 29 fe 34 c4 0f 0d a1 87 d5 dd 8b c8 b8 a7 ab 69 ed be 63 13 c8 58 e6 56 3c 7e 98 af ab b8>,
  chainCode:
   <Buffer ed 1c 6d 32 88 99 d6 ac ad 8d 27 46 4d 79 29 53 83 bc 3d 47 9e 25 9d 0a 4d 59 1a 5b da 8f 4b f5>,
  _fingerprint: 747931124,
  parentFingerprint: 0,
  _identifier:
   <Buffer 2c 94 85 f4 30 bd 2c 99 6e ea 53 bd c7 ed 5b 22 e2 08 40 91> }
hdkeyWithBuffer ===> HDKey {
  versions: { private: 76066276, public: 76067358 },
  depth: 0,
  index: 0,
  _privateKey:
   <Buffer 15 49 3c 2b e2 a4 15 9c d9 82 b9 3c af 3d 70 5f d2 9b 9b ac 77 80 31 ca ea 21 6e fb eb fe 24 78>,
  _publicKey:
   <Buffer 02 2a ec b9 22 ae 00 1d 9d 0c b9 69 27 e5 50 ee 6c fd 60 74 1a c6 27 f1 02 89 fe 2c 29 3b 3c 73 41>,
  chainCode:
   <Buffer 26 07 1b 1d c7 92 44 cd 6b 8f fd 3e 12 56 5d 32 b9 bd ea 4c 21 96 43 7c d4 5f a4 7c 63 30 f5 5f>,
  _fingerprint: 722394980,
  parentFingerprint: 0,
  _identifier:
   <Buffer 2b 0e df 64 a4 76 bb 34 ed e2 5e 03 0b d6 02 cb df 7e 46 e4> }

It looks like a Buffer is created behind the scene anyway, but the value changes if I don't create a Buffer myself.

Why do we need a buffer? Should I create a buffer on my own?


texts:
I want to write a function let user deposit a fixed amount of eth to a specific address for registering purpose.

pragma solidity ^0.5.0;

contract Election {
    // Constructor
    address public chairman;

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

    function register() public payable{
        chairman.transfer(1.0);
    }
}

But this error threw out

  member 'transfer' not found or not visible after argument-dependent
  lookup in address


texts: How to get token holdings for an address?

texts:
I want to get token holding of an address with web3.js.
If I have an address, 0x00000.....123 is there a way I can get all the tokens that address hold, like etherscan shows the tokens and balances.

I think we can do this other way around, by getting token contract address and ask for balanceOf(address), but that will be a lengthy process, and I need to know tokens contract address beforehand.

Thanks for the help.


texts:
I saw different companies like Goldmint have on their roadmap this step "Migration to owned blockchain".

Could anyone explain how a "Migration" works from Ethereum to a private blockchain and what happens to all tokens already present on Ethereum (because are also exchanged)?


texts: Can i restrict peers to access certain functionalities in my contract and giving some the access to them?

texts: i want to make a contract with  functionalities and let other peers access that by giving permissions to certain functionalities to some and other ones to some.


texts: Is it possible that we have a contract that allows the user to mint contracts directly on rarible. If so, please guide how will this be accomplished. I want to mint erc-721 and erc-1155 tokens.


texts: Does --no-ancient-blocks affect on trace_call for the pending block?

texts:
Please explain how --no-ancient-blocks flag works for openethereum.
I've checked that with this flag I won't be able to make requests eth_getBlockByNumber for ancient blocks.
But what about transactions for pending blocks that rely on the state of contracts which were created in the ancient blocks?
For example,  there is a contract 0x123123123123123123 which was created in block_number=1. This contract has a public method getMyValue() which returns a stored value my_value. This state my_value was set in block_number=1.
Is it possible to make trace_call for the pending block to this contract and get this my_value for openethereum node which was synced with --no-ancient-flag?


texts: Why do constant state variables get initialised every time?

texts:
I was working with constant variables in a contract

contract X{

uint constant var1=now;
uint var2=now;

function checkConstant() returns(uint,uint){
    return (var1,var2);
}}

I was wondered each time I call checkConstant(..) , the return value of var1 was different but value of var2 was same. So, I do not understand when I declare a variable as constant why it gets initialised each time a function is invokend, ideally it should get an initial value at time of contract deployment and maintain this value throughout life of contract.


texts: TypeError: market.FileViewed is not a function while trying to watch event

texts:
I want to watch for fileViewed event and it throws TypeError: market.FileViewed is not a function in

marketplace.FileViewed{
           ^

My solidity contract:

pragma solidity ^0.5.0;

contract Marketplace {
    string public name;
    address owner;
    uint public fileCount = 0;
    mapping(uint => File) public files;

    struct File
    {
        uint id;
        string name;
        address owner;
        address sharedWith;
    }

    mapping(uint => Product) public products;

    struct Product {
        uint id;
        string name;
        address owner;
        address sharedWith;
    }

    event ProductCreated(
        uint id,
        string name,
        address owner,
        address sharedWith
    );

    event FileViewed(
        uint id,
        string name,
        address owner,
        address sharedWith
    );

    constructor() public {
        name = "File Sharing System";
        owner = msg.sender;
    }

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

    function addFile(string memory _name, address _address) onlyOwner public
    {
        fileCount++;
        products[fileCount] = Product(fileCount,_name,owner,_address);
        emit ProductCreated(fileCount, _name, owner, _address);
    }

    function viewFile(uint _id) public view
    {
        Product memory _file = products[_id];
        require(msg.sender==_file.sharedWith,"Not shared with you!!");
        emit FileViewed(fileCount, _name, owner, _address);
    }

}

This is my js:

marketplace.FileViewed(
    function(){
      if(this.state.account!=results.args.sharedWith)
      {
        window.alert("File not shared with you")
      }
      else
      {
        window.alert("File viewed")
      }
    })

  viewFile(id)
  {
    this.setState({loading: true})
    this.state.marketplace.methods.viewFile(id).send({from: this.state.account })
     .once('receipt', (receipt) => {
        this.setState({loading: false})
     })
  }


texts: How to stop and restart a multinode Ethereum private network?

texts: I am testing a multinode Ethereum private network setup with Docker, 1 bootnode, 1 node, 2 miners, netstats and 2 swarm, total 7 containers. When I stop and restart the containers, the chain stops producing blocks and gets stuck on the last block. How to fix this?


texts: Is there a GUI way to import chain data and what would be best practice?

texts:
I am trying to copy over chain data from one machine to another. Is there a way in the GUI to do this?
Is there a how to/best practice for putting 300+ GB of chain data on new machine and launching ethereum wallet successfully?
Do I launch ethereum wallet first then move chain data into file created? What would be proper steps to do this? I have tried but gotten 'can not connect to node' error


texts: what does verifying smart contract execution means?

texts:
I know that when somebody wants to run a function in a contract, she sends a transaction; and then a miner needs to run that function based on the function input received from the user, adding the contract output to a newly proposed block. The block is then propagated to every full-node to be verified, but

1- How can every full-node verify that every contract transaction is executed correctly by miners? Does the verifier receive the output of every contract in that block in addition to user input of the function; and then she has to run every contract and compare the result with the miner result? if so,

2- Verifying process is as expensive as mining, but why is still free (verifiers do not get any ether, unlike miners).

Simply, could anyone explain to me the mechanism in detail of verifying a block with contract transactions? What needs to be verified? how long does it take compared to mining a block?

Thanks


texts:
with any web3 or ethers provider I am getting this error.
This is suddently startedoccuring. Noticed it when my hardhat test cases started failing.
Is anyone else facing the same and has solution??
Any help appreciated!!


texts: Get smart contract info from transaction

texts:
Lets take for example this, we can see that it did not transfer any ether, it interacts with a contract (that's why there's the stamp of the contract creation/execution).
Is there a way to get in go-ethereum these specific values?
Basically, how to get what was in a transaction if it was not about ether (eg uniswap).


texts: Creating rinkeby account on windows using geth

texts:
I have been following this guide https://gist.github.com/cryptogoth/10a98e8078cfd69f7ca892ddbdcf26bc to create rinkeby test network account on geth. Is there any way to type the commands in step 3 in Windows? Because it is now optimized for mac and linux.

command is:

geth --datadir=$HOME/.rinkeby attach ipc:$HOME/.rinkeby/geth.ipc console


texts:
I bet this is a simple answer, but I'm just unable to fully understand.
Uniswap has liquidity. It can be added. But what function does it uses? the Transfer() one from the contract ?
I'm trying to find a way to track if someone adds liquidity to the pool, through the contract itself.
if anyone has knowledge about this I would appreciate, even if the answer isn't extremely detailed, I can still do more researches afterwards. Thank you


texts: What are some limitations of decentralized exchanges?

texts: The question is whether the decentralized exchange is lame or profitable ? I got a good review on this matter : https://cryptogeek.info/en/blog/decentralized-exchanges-pros-and-cons. Actually, I think that decentralized exchanges are getting popular and I don't know a good reason not to use them. But, maybe I missed something, is there other opinions or ideas?


texts: Solidity: Storing values in mapping causes high gas. Can I use bytes array?

texts:
I'm working with a contract which can pay revenues. This is how the main part of my code looks more or less:

for(uint i = 1; i <= newestId; i++)
{
    uint unitsAmount = user.units[i];
    if(unitsAmount == 0)
    {
        continue;
    }
    RevenueData storage r = RevenueData[i];
    revenue = revenue.add(r.revenueForUnit.mul(unitsAmount));
    uint j = i + 1;
    user.units[j] = user.units[j].add(unitsAmount);
    user.units[i] = 0;
}

If user takes revenue with id 6, but misses 7, and 8 is the newest, code will automatically give also revenue 7 to him.

This is working as expected, but the problem is it generates a lot of gas, on the ropsten with 1 gas price it takes 7 cents with newestId = 1, but ~28 cents when newestId is 7. On the main network it will be even 10 times more expensive because of gas price, so it makes the code impossible to withdraw any revenue.

I guess it's possible to make it somehow better. Can I replace mapping storage with bytes array and somehow pushing or pulling ints there?

I'm totally new with bitwise operations. The maximum amount of units is 200000000, so I guess if I can do it with bytes array it needs to work with uint24? And then save it in < 0, < 24, < 48? But these are only my suspections based on quick googling.

May I gently ask for any kind of tips or help? Thanks in advance.


texts: Problem importing my account to metamask

texts: i tried to import my myetherwallet account into metamask by entering private key and try to connect both account but my imported account does not show any tokens i tried it many times by unistalling and intalling it again through mobile and desktop but it does not work although my private key is correct because when i tried to to open myetherwallet trough the same private key it works and shows my all tokens


texts:
I have an array.

string[] private NameIndex;

i want to check if the same name is already exist in the array.If same name is exist it will return false and if not exist anf if name is unique it will add the new name in the array and return true.

NameIndex.push("BOB") - 1;

kindly help


texts: How to pay an Oracle with Link token if I have payable with Ethereum values?

texts:
First of all, I'm new to this smart contract world, and so I would like to apology if it's a stupid question. I'm programming with Remix and with Solidity as programming language.I have 2 files:
mainfile.sol:
[...]
function createSomething(string memory _name, uint _userProvidedSeed) payable public {
        require(msg.value >= productCost);
        //refound user if he/she pays more than the productCost value
        msg.sender.transfer(msg.value - productCost);

        getRandomNumber(_userProvidedSeed);
        _createProduct(_name, randomResult);
    }
[...]

and RandomNumberConsumer.sol that is an oracle for generating a random number:
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.6.6;

import "https://raw.githubusercontent.com/smartcontractkit/chainlink/master/evm-contracts/src/v0.6/VRFConsumerBase.sol"; //import of the VRFConsumerBase for generating random data

contract RandomNumberConsumer is VRFConsumerBase {

    bytes32 internal keyHash;
    uint256 internal fee;

    uint256 internal randomResult;

    event RequestRandomness(
        bytes32 indexed requestId,
        bytes32 keyHash,
        uint256 seed
    );

    event RequestRandomnessFulfilled(
        bytes32 indexed requestId,
        uint256 randomness
    );

    /**
     * Constructor inherits VRFConsumerBase
     *
     * Network: Kovan
     * Chainlink VRF Coordinator address: 0xdD3782915140c8f3b190B5D67eAc6dc5760C46E9
     * LINK token address:                0xa36085F69e2889c224210F603D836748e7dC0088
     * Key Hash: 0x6c3699283bda56ad74f6b855546325b68d482e983852a7a82979cc4807b641f4
     */
    constructor()
        VRFConsumerBase(
            0xdD3782915140c8f3b190B5D67eAc6dc5760C46E9, // VRF Coordinator
            0xa36085F69e2889c224210F603D836748e7dC0088  // LINK Token
        ) public
    {
        keyHash = 0x6c3699283bda56ad74f6b855546325b68d482e983852a7a82979cc4807b641f4;
        fee = 0.1 * 10 ** 18; // 0.1 LINK
    }

    /**
     * Requests randomness from a user-provided seed
     */
    function getRandomNumber(uint256 userProvidedSeed) internal returns (bytes32 requestId) {
        require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK - fill contract with faucet");
        uint256 seed = uint256(keccak256(abi.encode(userProvidedSeed, blockhash(block.number)))); // Hash user seed and blockhash
        bytes32 _requestId = requestRandomness(keyHash, fee, seed);
        emit RequestRandomness(_requestId, keyHash, seed);
        return _requestId;
    }

    /**
     * Callback function used by VRF Coordinator
     */
    function fulfillRandomness(bytes32 requestId, uint256 randomness) internal override {
        emit RequestRandomnessFulfilled(requestId, randomness);
        randomResult = randomness;
    }
}

the problem here, is that if I generate my product without the payment in ethereum, so by commenting "getRandomNumber(_userProvidedSeed);" it works perfectly and creates the product, obviously without the random number.
When I run it without commenting the above function, remix transaction prompt writes me this:
transact to xxx.xxx 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.

and in my opinion is a problem with my LINK balance which is 0 probably but generating the random number need to pay a fee to the oracle, as said in the getRandomNumber(..) function.
Can anybody help me? Thanks a lot in advance :P


texts: Why do we need ether in private quorum chain for transactions?

texts: I have created a private quorum chain network. If there is a balance in the account address only then transactions are happening. Why do we need ether balance in quorum private chain or is there something I need to give additionally to do transactions with out ether balance because I have read that quorum private chain doesn't require ether for transactions


texts: Quorum & web3j: Transaction has failed with status: 0x0. Gas used: 0. (not-enough gas?)

texts:
I'm doing some play & test with Quorum. I'm using example 7nodes with docker. The network is up and my simple smart contract is deployed with a set and a get function. When I call the set function with Quorum web3j I get below error:

  Transaction has failed with status: 0x0. Gas used: 0. (not-enough gas?)

Although the get function works fine. And also the set function works OK in remix ide. Has anyone seen this error before?

Here is the contract code:

pragma solidity ^0.4.25;

contract Test {

  uint256 number;

  constructor() public {}

  function set (uint256 n) public {
    number = n;
  }

  function get () public view returns (uint256) {
    return number;
  }
}


texts: Why am I having trouble connecting to the Infura mainnet?

texts:
I ran the below command, which I understood should've connected me to the mainnet:

curl -X POST \ -H "Content-Type: application/json" \ --data '{"jsonrpc": "2.0", "id": 1, "method": "eth_blockNumber", "params": []}' \ "mainnet.infura.io/my-token

but there appears to continue to be some issue.

Any idea why?
Have I made some syntax error, or am I supposed to be swapping out an actual block number for eth_blockNumber, or similar?

To make sure it's clear that I didn't make the following mistake, I did swap out 'my-token' for the 20 digit token Infura generated for me.

Thanks so much!


texts:
In remix I included the following code in an ERC-20 token:

address burnAddress = 0xbababababababababababababababababa;

The address is meant to send tokens to but the address itself will not be able to send funds to anyone else because there are conditionals in the transfer and transferFrom functions preventing it.

The reason for its existence is to lower the amount of coins in circulation.

Question:

In remix, you're able to run the compilation of the token and test it with different addresses, but I only see the ability to create a new address with the "+" button on the right of the word Account. Is there any way to specify an address in the Account dropdown?


texts: solidity how to transfer ether from different account

texts:
I have written  a smart contract for ICO.
Basically any funds that come to smart contract (by using fallback) function  is immediately transferred to beneficiary account.

Now after 10 days i wish to refund ethers if some audit fails , i use send or transfer function but as the contract itself does not have any ethers they are unable to refund

1) how can i initiate refund from other account in smart contract
2) do i need to do this on web3.js as i see an option there to specify "from" while transferring ethers


texts:
I'm using solidity compiler ^0.4.23, I added logs to the function at exception points like this:

function firstSaleDelivery(address _beneficiary, uint256 rate) public onlyOwner{
  require(!presaleOpen && !firstsaleOpen, "First Sale is NOT CLOSE");
  if(preSaleTokens >= 0){
      saleTokens = saleTokens.add(preSaleTokens);
      preSaleTokens = 0;
  }
  uint256 ethers = firstSaleFunds[_beneficiary];
  uint256 tokens = ethers.mul(rate);    // <u>
  require(saleTokens >= tokens, "NO Sale Tokens Available");
  if(ethers >= 5 && ethers <= 9 ){
    tokens.add((tokens.mul(10)).div(100));            // <u>
  }
  else if(ethers >= 10 && ethers <= 200 ){
    tokens.add((tokens.mul(25)).div(100));            // <u>
  }
  token.transfer(_beneficiary,tokens);
  saleTokens = saleTokens.sub(tokens);

}

When I invoke the function, and if I face any exception, I can't see these Logs, where I can see them?


texts: "The constructor should be payable if you send value. Debug the transaction to get more information. " error

texts:
hi i was trying to replicate reentracy attack that can exploit etherum contract

Below is the code

 pragma solidity ^0.4.19;
 contract Mutex {
 bool locked;

modifier noReentrancy() {
require(!locked);
locked = true;
_;
locked = false;
}

 function Mutex() public payable {
   locked=false;
}

function canBeAttacked() public  returns (uint) {
require(msg.sender.call.value(1 ether)());
return 7;
 }

/// This function is protected by a mutex
  function f() public noReentrancy returns (uint) {
require(msg.sender.call());
  return 7;
  }
 }

  contract attacker{
      bool again=false;
function attacker() public  {

   }
      function() public  payable{
             if(!again){
              again=true;
            Mutex(msg.sender).canBeAttacked();
         }
     }
   function payment(Mutex mutex) public {
        mutex.canBeAttacked();
    }
 }

But when ever i click call payment method of attacker contract (Deployed on Virtual VM java script on remix) i get the following error

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

What is wrong with this code?


texts:
I need to call the RPC method debug_traceTransaction but it's not present within the Go client.
I'd add a method that performs the call to the RPC endpoint but I'm wondering if there's a reason behind..? Too much to transform?
The Management API Wiki specifies that you can use debug.TraceTransaction(txHash common.Hash, logger *vm.LogConfig) (*ExecutionResurt, error) but that's not in the client's code.

Update:
I put here the basic code I'm using to make the call in case someone wants to do the same thing

func DebugTransaction(hash string) (string, error) {
    json := `{"id": 1, "method": "debug_traceTransaction", "params": ["` + hash + `", {"disableStack": true, "disableMemory": true, "disableStorage": true}]}`
    log.Println("Request with:", json)
    jsonByte := []byte(json)
    req, _ := http.NewRequest("POST", ethereumNodeAddress, bytes.NewBuffer(jsonByte))
    req.Header.Set("Content-Type", "application/json")
    resp, err := client.Do(req)
    if err != nil {
        log.Println(err)
    }
    body, err := ioutil.ReadAll(resp.Body)
    log.Println("Request info: " + resp.Status + " " + string(body))
    return string(body), err
}


texts: Is it worthwhile to store my supply chain product data on the blockchain using a smart contract?

texts:
I'm currently developing an android app that uses the Web3j framework (Java) to interact with my private Ethereum blockchain (running on Ganache). The app is a supply chain tool that will let users create orders for products and use Ethereum for creating transactions to ensure immutability and traceability.

Is there a good reason to store the product data/records (i.e. product name,description) on a smart contract that I can request using the Web3j framework in my app, or should I just use a standard database?


texts: Final year Project using Block-Chain technology

texts: What Type of Application i can develop using Smart Contracts? (I Need Suggestions for my final year project)


texts: How to get a contract verified on etherscan?

texts:
I'm having a hard time getting a contract verified on Etherscan.

I deployed the contract using Ethereum Wallet, I can effectively find it on Etherscan but when I copy-paste the exact same code to the verification, I get the error:

  Sorry! The Compiled Contract ByteCode does NOT match with the Contract Creation Code for ...

Am I missing the point or something? How to correctly get a contract verified on etherscan?