texts:
I know that when smart contracts run in Ethereum, there are parts that create and runtime, and use function selector to find and execute body of function.
I have built geth on my computer from a source code, and then modified to print the running opcode.

After that, I compiled the following smart country contents and made a js file.

  contract A {
      uint num;
      constructor (uint n) public {
          num = n;
      }

      function add(uint n) public {
          num += n;
      }

      function nums() public view returns (uint) {
          return num;
      }
 }

js file is like,

var aBin="608060405234801561001057600080fd5b506040516101293803806101298339818101604052602081101561003357600080fd5b8101908080519060200190929190505050806000819055505060cf8061005a6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80631003e2d2146037578063d5b13259146062575b600080fd5b606060048036036020811015604b57600080fd5b8101908080359060200190929190505050607e565b005b60686090565b6040518082815260200191505060405180910390f35b80600080828254019250508190555050565b6000805490509056fea264697066735822122021d02222a0c22422593d1d3ea567fddf11eff7a3a15eeb52997e7e8fc164ea6464736f6c63430006010033"
  var aAbi =[{"inputs": [{"internalType": "uint256","name": "n","type": "uint256" }], "stateMutability": "no    npayable","type": "constructor"}, {"inputs": [{"internalType": "uint256", "name": "n","type": "uint256"}],    "name": "add","outputs": [],"stateMutability": "nonpayable","type": "function"},{"inputs": [],"name": "num    s","outputs": [{"internalType": "uint256","name": "", "type": "uint256"}],"stateMutability": "view","type"    : "function"}]

And,

> loadScript("test1/A.js")
true
> var aAbi = aAbi
undefined
> var aBin = '0x'+aBin
undefined
> var conA = eth.contract(aAbi)
undefined
> personal.unlockAccount(eth.accounts[0], "*mypassword*")
true
> var contractA = conA.new(2,{from:eth.accounts[0], data:aBin, gas:'7000000'})

when I try to execute add function,

> contractA.add.call(1)

Opcodes looks like this

[op: PUSH1, operation: 943840]
[op: PUSH1, operation: 943840]
[op: MSTORE, operation: 93ee00]
[op: CALLVALUE, operation: 93c020]
[op: DUP1, operation: 94c830]
[op: ISZERO, operation: 9398f0]
[op: PUSH1, operation: 943840]
[op: JUMPI, operation: 93f570]
[op: JUMPDEST, operation: 93f720]
[op: POP, operation: 93ebe0]
[op: PUSH1, operation: 943840]
[op: CALLDATASIZE, operation: 93c500]
[op: LT, operation: 938d10]
[op: PUSH1, operation: 943840]
[op: JUMPI, operation: 93f570]
[op: PUSH1, operation: 943840]
[op: CALLDATALOAD, operation: 93c2d0]
[op: PUSH1, operation: 943840]
[]

If you look at the output opcode, it was finished before reach to function selector (1003e2d2).

If performed correctly, ADD opcode should exist but is not visible in the output results.

What do I have to do to execute function?


texts: ethervault.io has shut down - are my coins all gone/stolen?

texts:
an online wallet i used for about 6 months called www.ethervault.io has recently completely shut down - no website, phone numbers disconnected, email all bouncing back.

how do i access my coins? have they been stolen by the site's owners? seriously worried! please help!


texts:
I have one solidity file, inside that file I have a this function:

struct OriginInfo{
    string 1;
    uint32 2; //In timestamp
    uint8 3;
    address 4;
    bool 5;
}

function insertOrigin(string _1, uint32 _2, uint8 _3, address _4) external pure {
    OriginInfo(_1, _2, _3, _4, true);
}

And in a another file I import the previous sol file and I call the function insertOrigin(). The import is great done but the problem is that i dont now how to return a struct in the function and in the other contract get that struct to append to origin param inside the Travel struct.

Any help?? Its that posbile to do??


texts:
This question is related to these questions.

Is there any tool that allows for step-by-step contract debugging? I have tried using mix but it really is broken at this point: contracts don't get deployed, transactions are never mined, etc.

Edit:

The duplicate is about testing functions not debugging them step-by-step.


texts: When is it appropriate to use "bytes" (or bytes1 - bytes32) in Solidity?

texts:
Upon reviewing prior questions and answers, I understand that "bytes" should be used for raw byte data of arbitrary length and "string" for UTF-8 data of arbitrary length.  I also understand that if I have an input parameter of type "bytes", the input should be in the format "["0x4a", "0x69", "0x6d", ..."0x20"]" (without the quotes).

However, to enter data means converting it to bytes first, and it also means that bytes data is returned through getter functions.  I know using "bytes" costs less gas and is easier for the VM to read, but how is this dealt with in the interface?

For example, in the following code, I have changed the input "_custname" from a string type to bytes32, as it is reasonable to limit the length of a person's name.  But this means I must enter their name in hex/unicode format, and retrieve it in hex/unicode as well.  Would I be better off using a string here?  Or perhaps I should add another function that converts it back to string data (though this seems like it would cost more gas than simply starting with string)?  Do people typically use bytes in Solidity, then have it converted on the Javascript front end?

uint8 public CarOwnerID;
Customer[] public carowners;
mapping(address => uint8) carAddrIndex;
mapping(string => uint8) carLicIndex;

function newCarOwner(address _address, bytes32 _custname, string _color, string _make, uint16 _year, string _license, bool) onlyMember public {

    carAddrIndex[_address] = CarOwnerID;
    carLicIndex[_license] = CarOwnerID;

    carowners.push(Customer(_address, _custname, _color, _make, _year, _license, true));

    CarOwnerID ++;

}


texts: What is the meaning of a permissioned blockchain? I know it is a private blockchain, but why is it called permissioned?


texts:
I wanted to Fork geth source code to create my own currency like ethereum but changing the currency name. I want it to be able to carry smart contracts also that's why I am not forking bitcoin.
Is there any guide to do that? is it applicable already?
can anyone give me hints on where to start from or a roadmap?
I have been searching for that and found no useful resources.


texts: How to generate address from xpub in JS?  Should i use BIP39 or 44? If yes, how exactly?


texts: How to interface function of deployed contract in new contract?

texts:
I have deployed Standard token contract using mist. Now I want to create interface functions for the deployed contract.

contract MyToken {
    function mint(address _to, uint256 _amount) onlyOwner returns (bool);
}

contract NewContract {

    Mytoken token;

    uint256 public rate;

    function NewContract(uint256 _rate){
        rate = _rate;
    }

    function () payable {
        token.mint(msg.sender, msg.value);
    }
}

First issue is I can't create interface for those functions that have some custom modifiers attached i.e onlyOwner. If I remove the modifer onlyOwner, I am able to deploy using mist, but when I transfer some amount to this contract it throws callback contain no result Gas required exceeds limit.


texts: First time writing a smart contract , please help me check are there any vulnerability in my code

texts:
This is the first time I write a smart contract and I'm going to use it for real application , so I hope there isn't any vulnerability or exploit since smart contract is immutable
This contract able to receives transaction from any address but only the owner eligible to withdraw

pragma solidity ^0.4.17;

contract EtherTransferTo{
address public owner;

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

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

}

function () payable public {
    // nothing to do!
}

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

function withdraw(uint amount) onlyOwner returns(bool) {
    require(amount <= this.balance);
    owner.transfer(amount);
    return true;

}

}

I know it is stupid to ask for help like this , but there isn't any friends of mine know programming ,  much appreciate if anyone could help


texts: Within the Solidity Docs it's pretty much implied from various bits of example code that a function declaration needs a returns declaration to return an object, but doesn't seem to be actually explained why. Is this because of type checking? What other languages use return declarations? Where is this bit of Solidity syntax derived from? Thanks


texts: How to disconnect MetaMask wallet using Web3modal

texts:
I am using metamask with kovan to connect to the wallet
import React, { useState, useEffect} from 'react';
import Web3 from "web3";
import Web3Modal from "web3modal";
import Navbar from './components/navbar';

function App() {
const providerOptions = {};
const web3Modal = new Web3Modal({
  network: "mainnet", // optional
  cacheProvider: true, // optional
  providerOptions // required
});

  const [account, setAccount] = useState('');
  async function connect() {
    try {
      const provider = await web3Modal.connect();
      const web3 = new Web3(provider);
      const accounts = await web3.eth.getAccounts();
      setAccount(accounts[0]);
    } catch (err) {
      console.error(err);
    }
  }

  useEffect(() => {
    if (window.web3) {
      connect();
    }
  }, []);

   async function disconnect() {
    const clear = await web3Modal.clearCachedProvider();
  }

  return (
    <div>
     <Navbar account={account} connect={connect} disconnect={disconnect} />
    </div>
  );
}

export default App;

how do i disconnect from the metamask?


texts: How to make function signature? ERC223 ContractReceiver

texts:
Hi what does these lines mean?

function tokenFallback(address _from, uint _value, bytes _data) {
    ...
    uint32 u = uint32(_data[3]) + (uint32(_data[2]) << 8) + (uint32(_data[1]) << 16) + (uint32(_data[0]) << 24);
    tkn.sig = bytes4(u);
}

I know tkn.sig is the 4 bytes signature of function. But could someone explain how those two lines work?


texts: Multiple inherintance: solidity docs example explanation

texts:
I found this example on the docs:

pragma solidity ^0.4.22;

contract owned {
    constructor() { owner = msg.sender; }
    address owner;
}

// Use `is` to derive from another contract. Derived
// contracts can access all non-private members including
// internal functions and state variables. These cannot be
// accessed externally via `this`, though.
contract mortal is owned {
    function kill() {
        if (msg.sender == owner) selfdestruct(owner);
    }
}

// These abstract contracts are only provided to make the
// interface known to the compiler. Note the function
// without body. If a contract does not implement all
// functions it can only be used as an interface.
contract Config {
    function lookup(uint id) public returns (address adr);
}

contract NameReg {
    function register(bytes32 name) public;
    function unregister() public;
 }

// Multiple inheritance is possible. Note that `owned` is
// also a base class of `mortal`, yet there is only a single
// instance of `owned` (as for virtual inheritance in C++).
contract named is owned, mortal {
    constructor(bytes32 name) {
        Config config = Config(0xD5f9D8D94886E70b06E474c3fB14Fd43E2f23970);
        NameReg(config.lookup(1)).register(name);
    }

    // Functions can be overridden by another function with the same name and
    // the same number/types of inputs.  If the overriding function has different
    // types of output parameters, that causes an error.
    // Both local and message-based function calls take these overrides
    // into account.
    function kill() public {
        if (msg.sender == owner) {
            Config config = Config(0xD5f9D8D94886E70b06E474c3fB14Fd43E2f23970);
            NameReg(config.lookup(1)).unregister();
            // It is still possible to call a specific
            // overridden function.
            mortal.kill();
        }
    }
}

// If a constructor takes an argument, it needs to be
// provided in the header (or modifier-invocation-style at
// the constructor of the derived contract (see below)).
contract PriceFeed is owned, mortal, named("GoldFeed") {
   function updateInfo(uint newInfo) public {
      if (msg.sender == owner) info = newInfo;
   }

   function get() public view returns(uint r) { return info; }

   uint info;
}

why does the last contract inherit from "owned, mortal, named("GoldFeed")", couldn't be just named("GoldFeed") given that it is already inheriting the other two contracts?


texts: Truffle Migrations Account Locked Error with --network command

texts:
I have started a private blockchain using the command,

geth --networkid 1337 --datadir ~/home/xyz/testnet --ipcpath /home/xyz/.ethereum/geth.ipc --rpc --rpcapi eth,web3 --rpcport 8545 --rpcaddr localhost --rpccorsdomain "*";

Next, in another terminal console, I start the miner and unlock my test account,

> miner.start(1)
true

> personal.unlockAccount(web3.eth.coinbase)
  Unlock account 0xSomeAddress
  Passphrase:
  true

My truffle.js file contains the following,

module.exports = {
build: {
  "index.html": "index.html",
   "app.js": [
     "javascripts/app.js"
   ],
  "app.css": [
    "stylesheets/app.css"
   ],
  "images/": "images/"
},
networks: {
"staging": {
  network_id: 1337,
  from: "0xAddress" // Unlocked Address
 }
},
rpc: {
  host: "localhost",
  port: 8545
 }
};

Finally, in another terminal, I run and compile the truffle application using,

truffle compile
truffle migrate --network staging

I get the below Account locked Error like below,

Running migration: 1_initial_migration.js
  Deploying Migrations...
  Migrations: 0xSomeAddress
Saving successful migration to network...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: account is locked
   at Object.InvalidResponse (/usr/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/errors.js:35:16)
   at /usr/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/requestmanager.js:86:36
   at request.onreadystatechange (/usr/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:114:13)
   at dispatchEvent (/usr/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
   at setState (/usr/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
   at IncomingMessage.<anonymous> (/usr/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13)
   at emitNone (events.js:91:20)
   at IncomingMessage.emit (events.js:185:7)
   at endReadableNT (_stream_readable.js:974:12)
   at _combinedTickCallback (internal/process/next_tick.js:74:11)
   at process._tickDomainCallback (internal/process/next_tick.js:122:9)

Which part am I missing here? Is the process that I followed correct?
The same code runs sublimely on testrpc but not on this private blockchain, what essential part am I missing?

Please advice.


texts:
According to this article, once a validator performs a voluntary exit, he can not rejoin:

If you’ve performed a voluntary exit, or been slashed, you won’t be able to rejoin. This means if you want to be a validator again, it’ll require an additional 32 ETH deposit and a new validator account.

How is this possible? If this is true, it would either make the withdrawn ETH "tainted" and non-fungible (creating a whole new market), or it would be very easy to circumvent, allowing for "laundering" the withdrawn ETH to be re-staked.


texts: How to write a smart contract for access level (read/write)?

texts: I have seen a couple of tutorials on how to code smart contracts, but I can not quite gather how to write one for permission and access level on a blockchain. How can you grant access to a user to read/add/edit or just read/write?


texts: Can I Make A Contract A Keyholder to a Multisig Wallet?

texts: As the title says, I want to make a smart contract one of the keyholders to a multisig wallet so that transactions from the wallet can be approved if they meet certain conditions. I think this should be possible but I'm not sure which method of the basic multisig wallet my contract should be calling. Also how can my contract know when it's appropriate to call the method or does the multisig wallet itself actually call the individual keyholders' accounts and I just need to specify a response?


texts: why x(function setArr) is not being returned?

texts:
pragma solidity >=0.5.0 <0.7.0;
contract Example{
    uint256[3] x;
    function setArr(uint256[3] memory y) public returns(uint256[3] memory){
        x=y;
       return getArr(x);
    }
    function getArr(uint256[3] storage z) internal pure returns(uint256[3] memory)
    {  return z;
    }
}


texts:
the default value for uint variable is 10
now on function call, I want to change this value to 0

steps to reproduce:

copy the following code to remix:

contract test {
    uint128 public aPos=10;
    function updateQuota( uint128  _Quota){
        aPos = _Quota;
    }
}

Use the environment as a web3 provider (configure local ganache server with remix ID)
Deploy contract.
Call updateQuota function with parameter as 0
Shows error as

  "transact to test.updateQuota errored: base fee exceeds gas limit "

.

Question: how to assign zero value to uint variable when we work with the web3 provider (local ganache server)


texts: Problem Internal Transaction Ethereum ( Funds dont appear in my wallet)

texts:
I have some funds frozen in ‘internal transactions’ and dont appear in my wallet ethereum.
I sended ethereum with exchangue “Buddha” to my wallet, and them work sending ethereum with smart contracts but i see that wallet Blockchain dont support it.
My wallet Ethereum is this:
0xA8C74d91114C9971866ad4063B922C8cEE45cCC5

I offer 1 ethereum who can help me solve it
https://www.blockchain.com/eth/address/0xa8c74d91114c9971866ad4063b922c8cee45ccc5?view=internal


texts: Why is data location not required to be specified for bytes32?


texts: How is the signature generated when the function does not have parameters?

texts:
When the function has parameters, Solidity generates its signature by adding the parameter types after the function name, in between brackets, and taking a keccak256 hash of the resulting string. As an example:
sendMessage(string,address)

The signature of this function is 0xc48d6d5e.
However, what if the "string" and "address" parameters do not exist? Would Solidity take the keccak256 hash of sendMessage, sendMessage(), or something else?


texts: how to call deployed smartcontract with sendRawTransaction

texts:
with this code i want to call my token smartcontract's transfer function. as per my knowledge i have to add this ".transfer(address,amount)" to data field. am i correct? also i am using web3 0.20. in this version i have to use getData right?
 so that will be var dataforTx = mycontract.tranfer.getData(address,amount);
then add that dataforTx to data field?

  var Tx = require('ethereumjs-tx'); var privateKey = new
  Buffer('e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109',
  'hex')

  var rawTx = {   nonce: '0x00',   gasPrice: '0x09184e72a000',
  gasLimit: '0x2710',   to:
  '0x0000000000000000000000000000000000000000',    value: '0x00',
  ****data:
  '0x7f7465737432000000000000000000000000000000000000000000000000000000600057'
  }** //how to get hex value of my dataforTx????????**

  var tx = new Tx(rawTx); tx.sign(privateKey);

  var serializedTx = tx.serialize();

  //console.log(serializedTx.toString('hex'));

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

i am still not able to transfer token.it returns hash value but not reflecting any balance in other account. and if i use balanceOf then how to catch output of balanceOf function in sendRawTransaction


texts: No such file or directory: 'solc': 'solc'

texts:
I have been trying to follow the following tutorial

[https://github.com/adamyala/Your_First_Decentralized_Application_Python]
     But the following error occurs:

I have followed all the steps in the tutorial. Also, I have made sure that solc is installed using npm install -g solc in the virtualenv.

Is there anybody that can help?

Many thanks.


texts: raw transactions to send ERC20 token fails on private network(POA)

texts:
I am trying to transfer ERC20 tokens on private ethereum network(POA)

Transaction flow:

raw tx object creation on backend.

   {
        "gasLimit": 37000,
        "gasPrice": 4000000000,
        "to": <contract address>,
        "value": 0,
        "chainId": 15,
        "data": "0xa9059cbb000000000000000000000000ff70ccdc55a319428fd88809ce848a61087ab2ac0000000000000000000000000000000000000000000000003782dace9d900000"
    }

sign tx on front end.

 { messageHash:
   '0x4bbc38ad53cf154ca1445365c9007dfeca0c0cce251945feb2a8ff3bd6de8795',
  v: '0x42',
  r:
   '0xa664add8c614f05d52104a29b16312744cb8849bc5af5cb78a9ba7daf19e8a12',
  s:
   '0x38c055e9a7c1e5b0321f5d82d832d91da3a2207025756b84c44b8ca31cbbb4f2',
  rawTransaction:
   '0xf8a80884ee6b280082908894324e19e928239d0c7f8b93247d559b54a4e0d03080b844a9059cbb0000000000000000000000008d75f6db12c444e290db995f2650a68159364e2500000000000000000000000000000000000000000000000270801d946c94000042a0a664add8c614f05d52104a29b16312744cb8849bc5af5cb78a9ba7daf19e8a12a038c055e9a7c1e5b0321f5d82d832d91da3a2207025756b84c44b8ca31cbbb4f2' }

submit tx from backend data.

 web3.eth.sendSignedTransaction(signedData)
        .on('receipt',function(receipt:any){
            if(receipt.status == false)
                throw new Error('transaction failed');
            sendSuccessResponse(res, {
                txId : receipt.transactionHash
            });
        })
        .catch(function(error:any){
            next(error);
        })

But when I try to sign transaction on android(using web3j) and submit from backend(web3.js). It fails sometimes(for random receiving addresses such as : 0xFF70ccDC55a319428FD88809cE848a61087Ab2aC) with error:  Transaction has been reverted by the EVM

    public String sign(RawTransaction rawTransaction, Credentials credentials) {
        byte[] signedMessage;
        signedMessage = TransactionEncoder.signMessage(rawTransaction, bigIntToByteArray(15), credentials);
        return Numeric.toHexString(signedMessage);
    }

version:

Web3.js - 1.2.4

Web3j - org.web3j:core:4.2.0-android

Geth - Geth/v1.9.6-stable-bd059680/linux-amd64/go1.11.5

Network
consensus : POA

No. of nodes : 2


texts: Help ! Error -13 trying to connect my local files to remix Ide

texts:
Hi i am trying to setup work environment by connecting local files to remix ide
i keep getting this error when i run code
remixd -s "absolute url path" --remix-ide https://remix.ethereum.org
and the output [Error: EACCES: permission denied, open '/usr/local/lib/node_modules/@remix-project/remixd/origins.json'] { errno: -13, code: 'EACCES', syscall: 'open', path: '/usr/local/lib/node_modules/@remix-project/remixd/origins.json' } [WARN] You may now only use IDE at https://remix.ethereum.org to connect to that instance [WARN] Any application that runs on your computer can potentially read from and write to all files in the directory. [WARN] Symbolic links are not forwarded to Remix IDE


texts: Different byteCode generated between block explorer and standard json input

texts:
I have deployed a contract and want to verify it, but when I used the same code with same configurations of compiler to verify it, it gave me negative result. Thus I tried to decompile these two byteCodes by using https://ethervm.io/decompile, the image below is the result of difference between two decompiled byteCodes.
Do anyone has any idea about how these differences meant? Looking for your help, thanks!


texts: Metamask wallet lost after Chrome Extension crashed

texts:
I installed Metamask a long time ago and sent 1 ETH to it for testing last month. Today the Chrome extension crashed and was disabled by Chrome. When I re-enable it, it asks me for my seed phrase which I don't have anymore. I read that creating account again should re-generate the same seed phrase and wallet. But after I did that I got a new account with 0 eth balance.

I had no idea it was this easy to blow away my Ethereum account file... I did not even re-install Metamask or Chrome. Is there anyway for me to recover my previous account? Is the previous account file still encrypted on disk somewhere?


texts: How to get the "birth block" of a contract?

texts: How does one query the "birth block" of a contract using web3?


texts: Is there a reason why minting is excluded in erc721 interface?

texts:
So the EIP-721 standard says,

Creating of NFTs ("minting") and destruction NFTs ("burning") is not included in the specification. Your contract may implement these by other means.

interface ERC721 /* is ERC165 */ {
    event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
    event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);
    event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);

    function balanceOf(address _owner) external view returns (uint256);
    function ownerOf(uint256 _tokenId) external view returns (address);
    function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable;
    function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;
    function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
    function approve(address _approved, uint256 _tokenId) external payable;
    function setApprovalForAll(address _operator, bool _approved) external;
    function getApproved(uint256 _tokenId) external view returns (address);
    function isApprovedForAll(address _owner, address _operator) external view returns (bool);
}

I get what it says, but I think it would have been better that function mint  was included in the standard in the first place since almost every erc721 contract uses below format?
function mint(address _to, uint256 _tokenId);

Any valid reason that mint was ommited from the standard?


texts: Variable not being set to msg.sender in constructor

texts:
Having a weird issue with Solidity and web3.js 1.0. Any help would be much appreciated.

Here's my Solidity code:

pragma solidity ^0.4.16;

contract Test {

    address public contractOwner;

    function TestContract() public {
        contractOwner = msg.sender;
    }

    function foo() constant returns(address) {
        return msg.sender;
    }

}

However calling the automatically-generated getter method for the address public contractOwner produces an unexpected result.

> var deployed;
undefined
> var contract = new web3.eth.Contract(abi)
undefined
> accounts[0]
'0x78924d231848a2d37781e42A2Fe30737F19b6c5E'
> contract.deploy({data: bytecode}).send({
... from: accounts[0],
... gas: 3000000
... }).then((_deployed) => { deployed = _deployed })
Promise {
  _bitField: 0,
  _fulfillmentHandler0: undefined,
  _rejectionHandler0: undefined,
  _promise0: undefined,
  _receiver0: undefined }
> deployed.setProvider(provider)
true
> deployed.methods.foo().call().then(console.log)
Promise {
  _bitField: 0,
  _fulfillmentHandler0: undefined,
  _rejectionHandler0: undefined,
  _promise0: undefined,
  _receiver0: undefined }
> 0x78924d231848a2d37781e02A2Fe30v37F19b6c5E
> deployed.methods.contractOwner().call().then(console.log)
Promise {
  _bitField: 0,
  _fulfillmentHandler0: undefined,
  _rejectionHandler0: undefined,
  _promise0: undefined,
  _receiver0: undefined }
> 0x0000000000000000000000000000000000000000

As you can see, foo() works perfectly, but contractOwner() returns an empty address. Should it not be 0x78924d231848a2d37781e42A2Fe30737F19b6c5E, which is what's passed as the from attribute during deployment?


texts: What do the strange tiny transactions executed at the same time during the ICO mean?

texts:
Exploring InChain ICO smart contract transactions.
Smart contract address is
0x162ac26e2f0fe036c3a3d370c118de0b6c883083

There are many tiny amount transactions executed at the same time. Like this, for example:
https://etherscan.io/tx/0xb515d370fc6912a1ee88ed371035906e5c4d50f94009c52c03a4eb7b23a5c9dd

Usually all these tiny transactions are executed from the addresses that were used to deposit funds to ICO some time before. For example:
https://etherscan.io/address/0xd0f0d00d85ca8237b9845d64d49098d03c3275fa

As you can see there was a transfer of 19.99 Ether at block 2516173. 5 hours later 0.00571868 Ether were sent to the same contract.
Almost all the ICO transactions have the same pattern. One incoming transaction from some exchange wallet and two or more transactions to the ICO contract. And all the addresses have a balance like 0.000xxxxx Ether now.

I would like to know how is that possible that a large number of tiny transactions are executed at the same time from the large number of addresses (that belong to different people in theory)?
Does it mean all the addresses are managed from one centralized point? To execute all the transactions at the same time the wallets should be unlocked simultaneously. This can be done with some APi or specialized script.
Or maybe the accepting contract can execute some kind of 'delayed' transactions that were authorized several hours before by the address owner?
Why all the accounts have a balance near zero now?
Is it possible to send all the funds from Ethereum Wallet and leave 0.000xxx Ether using Mist or geth for an unexperienced user? I tried to do that but usually 0.01 Ether were still kept by my wallet.


texts:
function checkOffers() public returns (bool){
    uint256 a = sha256(offerFromProducer);
    uint256 b = sha256(offerFromConsumer);
    if(a == b){
        return true;
    }
    return false;
}

Is there some method to compare two structs in Solidity?


texts: How to make smart contract call using INFURA and NodeJS web3js

texts:
I can not understand how I can prepare the transaction to be signed. Because INFURA does not support eth_sendTransaction but only eth_sendRawTransaction (INFURA API which then requires you to prepare a signed transaction) I have no idea how I can do that.

This is the code that I use to try send transaction, that it fails:

PrintProofOfWork.methods.printRequested(web3.utils.keccak256(gcodeHash)).send('0x' + serializedTransaction.toString('hex'))
        .then((result) => {
            log(`result of the invokation: ${result})`.red);
        }).catch((err) => {
        log(`error occurred: ${err})`.red);
    });

The error I get is:

  error occurred:  Error: Node error: {"code":-32601,"message":"The method eth_sendTransaction does not exist/is not available"})

Can anyone kindly show me how I can prepare a transaction that invokes the method of a Smart Contract with parameters, sign it and then send it with INFURA?


texts: Payable function error: The called function should be payable if you send value and the value you send should be less than your current balance

texts:
I want to create simple auction contract (see code below).
But newBid() function is not working.
To run this contract, you must first create an item newItem(name, price, time) and then run newBid(itemId) - check the code.

There is 2 files`
Auction.sol
pragma solidity ^0.7.0;
import "./Item.sol";

contract Auction {

    uint256 lastId = 0;
    mapping (uint256 => Item) idToItem;

    address admin;

constructor () {
    admin = msg.sender;
}

function newItem(string memory _name, uint256 _price, uint256 _time) public {
    lastId += 1;
    idToItem[lastId] = new Item(_name, _price, msg.sender, _time);
}

function newBid(uint256 itemId) public payable {
    Item item = idToItem[itemId];

    item.newBid(msg.sender, msg.value);
}

function timeLeft(uint256 itemId) public view returns(uint256){
    return idToItem[itemId].timeLeft();
}

function getMaxBid(uint256 itemId) public view returns(uint256) {
    return idToItem[itemId].getMaxBid();
}

}
Item.sol
pragma solidity ^0.7.0;

contract Item {
    // Global fee is 14% of item price
    uint256 fee;

    // Main Parameters of item
    string name;
    uint256 price;
    address payable public owner;
    uint256 time;
    bool sold;

    uint256 maxBid;

    struct Bid {
        address payable bider;
        uint256 amount;
    }

    Bid[] Bids;

    constructor(string memory _itemName, uint256 _price, address payable _owner, uint256 _time) {
        name = _itemName;
        price = _price;
        owner = _owner;
        time = block.timestamp + _time;
        sold = false;
    }

// Returns item ramaining time (in seconds)
function timeLeft() public view returns(uint256) {
    return time - block.timestamp;

}

// Registers new bid for this item.
function newBid (address payable _bider, uint256 _amount) public payable {
    if (block.timestamp + time > time) {
        sellItem();
        require(block.timestamp < time, "Sorry, time is up");
    }else {
        require(_amount > maxBid, "The bid must be higher than the current maximum bid");
        Bids.push(Bid( _bider, _amount ));

        fee = (_amount / 100) * 14;
    }
}

// Sells item and refunds money
function sellItem () private {
    address _maxAmountAddress;
    uint256 _maxAmount = 0;

    for (uint i = 0; i <= Bids.length; i++) {
        if (Bids[i].amount > _maxAmount) {
            _maxAmountAddress = Bids[i].bider;
            _maxAmount = Bids[i].amount;
        }
    }

    for (uint j = 0; j <= Bids.length; j++) {
        if (_maxAmountAddress != Bids[j].bider) {
            Bids[j].bider.transfer(Bids[j].amount);
        }
    }

    owner.transfer(_maxAmount - fee);
    sold = true;
}

// Returns max bid for the item
function getMaxBid () public view returns(uint256) {
    return maxBid;
}
}


texts: Where’s the equivalent of Yellow paper for Ethereum classic?

texts:
Ethereum classic performed changes never implemented on Ethereum like on mining. I do expect them to have their own paper for detailing this.
But it seems it’s not called the yellow paper…

Even on their Github’s user page and their GitHub’s Website I failed to find it…


texts: splitting contract in data and application contract

texts:
I made 2 contracts in 2 different solidity files. Lets for simplicity assume the contracts are called A and B. A contains data and some simple function calls, B contains more complex function calls. What I try to achieve now is for the functions in B to call the functions in A. In order to do so, I tried to define an interface in the file where contract B is defined. I do this as follows
B.sol
contract B
{
  function b1()
  {
     #implementation
  }
}
contract A
{
  function f1;
  function f2;
}

In A.sol I have the implementation of contract A:
A.sol
contract A
{
  #implementation
}

However, my compiler returns an error. It says that the contract A defined B.sol should be called abstract. According to the courses I followed, I shouldn't get this error. According to the courses this was the correct way to defined the interface of contract A inside B.sol in order for contract B to be able to use the functions defined in contract A. Anyone else knows what is the problem here and how to fix it ?


texts: Can geth sync only up to a specific block number?

texts:
Does geth have a mode where you can tell it to sync only up to a particular block number and then stop syncing (and still serve queries about the blocks it has)?  Or a mode where you can tell it to always stay N blocks behind the latest mainnet block?  Or a mode where it says running but only syncs up to block numbers that it's given dynamically?
(Or - does geth have fine-grained control over when to accept a new block?)


texts: In uniswap v2 periphery, how does the contract fetch token pair address?

texts:
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
    (address token0, address token1) = sortTokens(tokenA, tokenB);
    pair = address(uint(keccak256(abi.encodePacked(
            hex'ff',
            factory,
            keccak256(abi.encodePacked(token0, token1)),
            hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
        ))));
}

in the above function, how does this pairFor function work with these argument? I am not being able to understand how the token pair address is retrieved in the above function and what the parameters mean.


texts: Add html header fields to oraclize query

texts:
I want to send an oraclize query as a post function. I use the following syntax:

oraclize_query('URL', 'http://...', json_doc).

This schema works but without attributes for the html header.  How can I add fields to the header (for example: content-typ, host, etc.)?


texts: What caused the forks in the Schlesi testnet?

texts:
The Schlesi testnet was the first multiclient testnet for ETH2 clients.  Lighthouse, Prysm, Teku were in consensus before it forked.

What were the causes of the forks?  Is there a technical post mortem report on it?

Source


texts: Extracting mapping structure from storage of smart contract

texts: Is there a way to extract data stored in the mapping structure without the keys by simply reading the smart contract's storage? Also, what is the inline assembly for inserting a value in mapping using a key?


texts:
I am storing addresses on the blockchain for IPFS objects, and the addresses are more than 32 bytes. I was using bytes32 for testing but I have truncation. I am seeking a method to read data from the blockchain (array of strings) and then return that into the reactjs to process.

For example I have -

Zipfs.deployed().then(instance=>instance.getIpfsData());
 [ '0x516d586465315a5552556442524c68706f4178587a324b7a585371646f6e446d',
'0x516d6538414d69774d434d446478415936675a3338714a6b6570566b516b5964' ]

I was using bytes32[] but that is not working as a return as follows -

pragma solidity ^0.4.8;
contract Zipfs {

IpfsData[] public ipfsrecs;

struct IpfsData {
    bytes32 reviewData;
}

function addIpfs (bytes32 _reviewData) payable returns (bool success) {
    IpfsData memory newIpfsData;
    newIpfsData.reviewData = _reviewData;

    ipfsrecs.push(newIpfsData);
    return true;
}

function getIpfsData() constant returns (bytes32[]) {

    uint length = ipfsrecs.length;
    bytes32[] memory reviews = new bytes32[](length);

    for (uint i=0; i<ipfsrecs.length; i++) {
        IpfsData memory currentIpfsRec;
        currentIpfsRec = ipfsrecs[i];

        reviews[i]=currentIpfsRec.reviewData;

    }
    return (reviews);
}

}

What can I do as it appears arrays of strings are not supported?


texts: GeForce GTX 1070 - hashrate only 680 khash/s?

texts:
I am mining ArtByte and LiteCoin using a single GTX 1070 GPU. Everywhere on the internet I am reading that such a card can achieve 20+ MH/s. My card only gets as far as 680 khash/s. Am I missing something? How to investigate this issue?

For ArtByte I am using:

  cudaminer 2014-02-28 (beta).

For LiteCoin:

  ccminer 2.1 for nVidia GPUs by tpruvot@github ***
  Built with VC++ 2013 and nVidia CUDA SDK 8.0 64-bits

BR, Rene


texts: How to implement partition storage of geth blockchain data

texts:
I am running a geth archive instance in Linux. As the block data grows, it has occupied my 6.8TB hard drive resources. I want to know how to make the geth instance store the new block data to the new hard disk after I insert a new 4TB hard disk.
Hope the great Ethereum community can help me, thank you very much!


texts: Uniswap: How to find volatility tokens for trade?

texts: Is there any API calls to find volatility tokens for trade on Uniswap?


texts: Can a new node join the chain without bootnodes

texts: I added a brand new node into the private network, without bootnodes. Over time this node DIDN'T seem to add any peers to talk with. Is that normal and expected?


texts: Access Swarm content from a smart contract

texts: Right now there is no instruction in the Ethereum VM to access resources stored on Swarm. Is there a plan to add such a feature?


texts: Internal Transactions - How to find out the address of the contract that is calling?

texts:
i have been Googling for this answer, but i haven`t succeeded.
The  scenario is the following:  I have two contracts interacting with each other, and I want to make sure that they only respond to each other. Meaning that if anyone else, or other contracts try to call their functions, the transaction must be reverted.
In order to achieve that, tried adding something like "require(msg.sender==addrContractA)" to the functions that i want to restrict but it does not workout.
Please look at the example below.
contract B {
     // Some code here...
     address addrA;
     receive() public payable {
        require(msg.sender ==addrA, "Error- Sender not allowed");
        // Some more code here...
     }

    function setAddressA(address _addrA) public onlyOwner{ addrA = _addrA;}
}

contract A{
     // Some code here...
   address b;
   ...

   constructor(address payable _b) public {
       b =_b;
   }
   receive() payable external{
      ...
      b.transfer(msg.value);
   }
}

The system is expected to behave like this:

A person sends eth to contract A, contract A passes the value along to contract B.
When the value hits contract B, it must verify if the sender is contract A. Any value that did not pass through contract A must be refused by reverting the transaction.

Problem here is that I do not know what variable I could inspect to get the address of the "internal sender". Something like msg.sender, but the variable "msg.sender"  always returns the address of the wallet of the person who started the transaction ( who sent eth to contract A) rather than the address of contract A.
Basically, what i am asking is, if any contract in the ethereum network tries to interact with contract B, how do i find out it's address? I mean, i need to know the address of who is calling contract B in order to refuse it if it is not coming from A.
I read a little bit about internal transactions and i did not find any encouraging topics :(, so here i am looking for help.
Grateful to any reasonable suggestion!


texts: It's possible to listen contract event without knowing contract address?

texts:
I have a smart contract with an event where an account address is stored/indexed, and I want to get/advise about this event each time the account address is trigger by the event.

By eg, my solidity event: myEvent( address indexed _sellerAddress) where _sellerAddress is a personal account address

I want to know/be informed each time my _sellerAddress is mentioned is this event, but I don't know at this stage the smart contract address.

let me know if I'm not clear.

thanks


texts: How to get a signed transaction string when I've already got the r,s&v from signing?

texts: The signed transaction geneated by MyEtherWallet has a length of 200(chars) or more, but after signing, the total length of r(32 bytes),s(32bytes)and v , about 130 in chars is far less than that. So there must be some kind of encoding to put r,s&v together to form the signed transaction string.  I've tried RLP, but the length is still far too short, not to mention the correction. What is this encoding?  I'm writing an iOS app unable to use web3.js so I need to know the implementation


texts: Is it possible to tell that two addresses were derived from the same private key?

texts:
As we know, a single private key or seed phrase generates many addresses.

Is it possible for someone to determine that two addresses were derived from the same private key?


texts: Quorum: How to find the key used in privateFor

texts: I have a 3 nodes quorum network, which I created with the help of quorum maker. I am adding an new account to my first node, so that my first node now has 2 accounts on it. I want to find the public key that is required for the privateFor field for this new account. How do I go about doing it? I got the file in the keystore folder by I am not able to find the public key in the format required.


texts: How important is Solidity Assembly, as far as market-based on demand dApps are concerned?

texts: I am a beginner trying to learn Solidity, enough to be able to make useful dApps. So, is learning Solidity Assembly beneficial to me, as of now?


texts: How is the keccak256(a, b) function implemented?

texts:
I need to understand how keccak256(a, b) is implemented and how it differs from keccak256(a || b).

Is the content padded?

I need this because I do not want to allow for vulnerabilities where a user could fake a hash, for example by doing:
H(0xabc, 0xdef) = H(0xa, 0xbcdef) which would be a major security vulnerability.

Thank you


texts: truffle pet shop example question(address convert)

texts:
I have some question about truffle pet shop example ,here is the original link pet shop, when I work this command:truffle test , and I have some compile problem.

here is original code:

I have some compile issue that really don't understand , so I try to ask for help.

Thanks everyone read my question(help message).


texts: Status is Successful but got internal transaction out of gas?

texts:
I call a function with the transaction like this
https://ropsten.etherscan.io/tx/0x7d4dec3c0db2b700efae63ef3ffb5a33fc2335bd992fd37c48aa10560eb8156e
this fuction is a call from other contract,I wrote it like:
function tokenDeposit(address borrower,uint amount)public BorrowerExist(borrower) payable returns(bool){
      address platform_token=0x98e2F1c551c05447BAe0a753f5b9fE243d8194b6;
      bytes memory deposit_token=abi.encodeWithSignature("transfer_with_approve(address,address,uint256)",borrower,platform,amount);
            platform_token.call(deposit_token);
            return true;
        }

and the platform is :address platform="one of my walletaddress";
the contract 0x98e2F1c551c05447BAe0a753f5b9fE243d8194b6 has been deployed and I have tested the
"transfer_with_approve" function in it and it worked ,however when I tried to call that function,I got an internal transaction error :out of gas, but the transaction status returned success .Anyone know what happen to this and can help me solve with this problem, thanks!


texts: How much does it cost to issue a NFT currently on Ethereum?

texts: What does one need to do to issue their own NFT on ethereum? What are the fees involved? Do I have to launch my own smart contract to create nft's and how much does this cost? Or do I use someone else's contract to create an nft?


texts: Create a new contract from other contract by connecting to ganache-cli

texts:
I am trying to create a contract from other contract on gnache-cli using remix web3 provider but getting following error:

VM Exception while processing transaction: revert

The issue is that when I try it on the JavaScript VM (on remix), I am not getting any error. Kindly note that I am running ganache-cli with the following parameters:

ganache-cli -h 0.0.0.0 -p 8545 -l 3000000000

As a sidenote, I am able to deploy the contract... the problem appears only when deploying from another contract. In the ganache-cli console, I am getting this error:

Transaction: 0x1f77d94278c27412affe6be5f7bd50d6f95d47503fa6c302553e1a94cfb7111c
Gas usage: 2250998
Block Number: 3
Block Time: Fri Sep 28 2018 13:33:14 GMT+0400 (+04)
Runtime Error: revert

Version of tools used:

ganache-cli 6.1.8 (ganache-core: 2.2.1)
solc, the solidity compiler commandline interface: 0.4.24+commit.e67f0147.Linux.g++
npm: 6.4.1

Contract code:

pragma solidity ^0.4.24;

contract Test2{
    constructor() public{

    }
}

contract Test{

    function createInstance() public{
        address test2 = new Test2();
    }
}


texts: Is it possible to transfer amount from 1st account to 2nd when transfer function is invoked by 3rd account?

texts:
suppose here i have three accounts and they have some balances!!

i want to transfer balance of 1st account into 2nd account when transfer function is called by the 3rd account!

if this is possible then let me know!!

Thanks!!


texts: Syntax highlighting for Solidity VS Code extension not working on linux

texts: Even if the extension installation completes correctly, syntax highlighting does not work.


texts: Gas cost of multiple small transactions vs one large one

texts: On the main ethereum network would the gas cost be the same to post several small transactions or one large transaction if the overall data size is the exact same?


texts: What is the latest implementation of approveAndCall() - Solidity ˆ0.5.0

texts:
Just curious for some background on approveAndCall()

1) Is it initially an ERC223 method ? or is it officially part of the ERC20 interface ?

2) Also Im working with an old contract so Im wondering is there a newer more up to date way of achieving similar functionality but with Solidity ˆ0.5.0

3) And finally probably a dumb question but does adding in approveAndCall() to an existing ERC20 contract break its compatibility with exchanges and what not ? I read online elsewhere that it does as its not officially part of the specification


texts: How do I watch Events from multiple contracts

texts:
I wrote a script that is able to read events from one contract address and then paste it into a .csv. Now I would like to extend that script listening watching/reading the same event of several contracts but which are just executing activities from the "main" contract" via calls. These contracts are also created by the "main contract".

Right now I am using:

var instance = web3.eth.contract
var mycontract = instance.at


texts: (Solidity) Inheritance: how to add additional attributes to a struct in base contract?

texts:
This is a very simplified example but it of course extends to more complicated contracts too, I just haven't found an elegant solution.

contract Group {
    struct Person {
        uint age;
        bytes32 name;
    }
    mapping (address => Person) members;
}

contract RockBand {
    struct Musician {
        uint age;
        bytes32 name;
        bytes32 instrument;
    }
    mapping (address => Musician) members;
}

contract FootballClub {
    struct Player {
        uint age;
        bytes32 name;
        bytes32 position;
    }
    mapping (address => Player) members;
}

Now it makes sense to me to make a 'library' of sorts out of Group, and inherit from it in the other two contracts. But I haven't found a way to modify a defined struct in a child contract. The best I can come up with is:

contract Group {
    struct Person {
        uint age;
        bytes32 name;
    }
    mapping (address => Person) members;
}

contract RockBand is Group{
    struct MusicianExtra {
        bytes32 instrument;
    }
    mapping (address => MusicianExtra) membersMusicianExtra;
}

contract FootballClub is Group{
    struct PlayerExtra {
        bytes32 position;
    }
    mapping (address => PlayerExtra) membersFootbalExtra;
}

This is the same as above functionality wise, but it requires an additional mapping for the extra information. Also it will become confusing and messy in bigger contracts, and it probably is less efficient if you need to look in two mappings instead of one to get the information.

I hope someone in the community has some insight for me.

Thanks! :)


texts: Why specification of modifier without returns is incorrect?

texts:
I have contract with modifier onlyOwner and below 2 functions that must be implemented by child contract like:

function getBalance(address _address) public onlyOwner returns (uint256);
function setBalance(address _address, uint256 _amount) public onlyOwner;

First like is treated as correct but second one breaks compilation. I do not want this function returns anything meaningful. How to fix it?

Truffle v3.4.11 (core: 3.4.11)
Solidity v0.4.15 (solc-js)

Error:

browser/test.sol:21:86: ParserError: Expected type name
        function setBalance(address _address, uint256 _amount) public onlyOwner;

                                                                      ^


texts: What is the current size of the Ethereum State?

texts:
What is the current size of Ethereum's state in bytes?

I am not asking about the size of the blockchain with blocks headers, transactions and receipts. I am looking for the size of all the structure that is stored under the State Root (merkle trie).

If you don't have exact number, could you give an approximate? Or any quick idea on how to calculate it?


texts: Is it possible and convenient to address a small fee to the Dev wallet when a smart contract between 2 counterparts has been cleared?


texts:
I am going through a sample gas token code on Ethereum. The token mints some dummy smart contracts using CREATE2 and then calculates the address. Later on it destroys them to get the gas refund.
Minting part looks like this
 assembly {
        mstore(0, 0x746d4946c0e9F43F4Dee607b0eF1fA1c3318585733ff6000526015600bf30000)

        for {let i := div(value, 32)} i {i := sub(i, 1)} {
            pop(create2(0, 0, 30, add(offset, 0))) pop(create2(0, 0, 30, add(offset, 1)))
            pop(create2(0, 0, 30, add(offset, 2))) pop(create2(0, 0, 30, add(offset, 3)))
            pop(create2(0, 0, 30, add(offset, 4))) pop(create2(0, 0, 30, add(offset, 5)))
            pop(create2(0, 0, 30, add(offset, 6))) pop(create2(0, 0, 30, add(offset, 7)))
            pop(create2(0, 0, 30, add(offset, 8))) pop(create2(0, 0, 30, add(offset, 9)))
            pop(create2(0, 0, 30, add(offset, 10))) pop(create2(0, 0, 30, add(offset, 11)))
            pop(create2(0, 0, 30, add(offset, 12))) pop(create2(0, 0, 30, add(offset, 13)))
            pop(create2(0, 0, 30, add(offset, 14))) pop(create2(0, 0, 30, add(offset, 15)))
            pop(create2(0, 0, 30, add(offset, 16))) pop(create2(0, 0, 30, add(offset, 17)))
            pop(create2(0, 0, 30, add(offset, 18))) pop(create2(0, 0, 30, add(offset, 19)))
            pop(create2(0, 0, 30, add(offset, 20))) pop(create2(0, 0, 30, add(offset, 21)))
            pop(create2(0, 0, 30, add(offset, 22))) pop(create2(0, 0, 30, add(offset, 23)))
            pop(create2(0, 0, 30, add(offset, 24))) pop(create2(0, 0, 30, add(offset, 25)))
            pop(create2(0, 0, 30, add(offset, 26))) pop(create2(0, 0, 30, add(offset, 27)))
            pop(create2(0, 0, 30, add(offset, 28))) pop(create2(0, 0, 30, add(offset, 29)))
            pop(create2(0, 0, 30, add(offset, 30))) pop(create2(0, 0, 30, add(offset, 31)))
            offset := add(offset, 32)
        }

        for {let i := and(value, 0x1F)} i {i := sub(i, 1)} {
            pop(create2(0, 0, 30, offset))
            offset := add(offset, 1)
        }
    }

The code clearly creates n number of smart contracts, but what's the significance of using mstore at the beginning. Also, I don't understand significance of the 30 in the create commands and the use of pop. Why are they needed?
Here comes the burning part
Contract tries to get the address of next burnable address based on already burnt tokens and then uses it as salt to generate the address of the token
function computeAddress2(uint256 salt) public view returns (address) {
    bytes32 _data = keccak256(
        abi.encodePacked(bytes1(0xff), address(this), salt, bytes32(0x3c1644c68e5d6cb380c36d1bf847fdbc0c7ac28030025a2fc5e63cce23c16348))
    );
    return address(uint256(_data));
}

function _destroyChildren(uint256 value) internal {
    uint256 _totalBurned = totalBurned;
    for (uint256 i = 0; i < value; i++) {
        computeAddress2(_totalBurned + i).call("");
    }
    totalBurned = _totalBurned + value;
}

How does just calling the contract is destroying it ? Where is the code of deployed dummy contract ? I need help in understanding the flow.


texts: Use testnet chain config when starting node

texts:
I'm following the instructions for creating an Android mobile client from here.  I have successfully started a node but I'm not sure which chain I'm connected to.  My guess is its mainnet instead of testnet.

How would I go about connecting to the testnet instead of the mainnet?  I have tried
ChainConfig testnet = Geth.gettestnetChainConfig(); but can't find any functions which take a ChainConfig as an argument.  I've scoured the go code as well.


texts: If someone would mine with three GeForce 1070 cards on Ubuntu 16.04, is it necessary to plugin the SLI bridges?


texts: How does automatic selling and buying with the constantly flowing price work?

texts:
From the docs:

  AUTOMATIC SELLING AND BUYING

  So far, you've relied on utility and trust to value your token. But if
  you want you can make the token's value be backed by ether (or other
  tokens) by creating a fund that automatically sells and buys them at
  market value.

  First, let's set the price for buying and selling:

uint256 public sellPrice;
uint256 public buyPrice;

function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner {
    sellPrice = newSellPrice;
    buyPrice = newBuyPrice;
}

  This is acceptable for a price that doesn't change very often, as
  every new price change will require you to execute a transaction and
  spend a bit of ether. If you want to have a constant floating price we
  recommend investigating standard data feeds

If you check the link, you'll probably find that it does not explain how to make the price constantly floating. So how to do this?


texts: Function _setTokenURI() in ERC721 is gone in OpenZeppelin ^0.8.0 contracts

texts:
We had the following mapping to manage the URIs for ERC721 tokens in OpenZeppelin contracts until pragma ^0.7:
// Optional mapping for token URIs
mapping (uint256 => string) private _tokenURIs;

Therefore, we had a function to pass the token ID and URI in order to store the URI, so the call would be:
_setTokenURI(_tokenId, _tokenURI);

However, I see this whole functionality and associated checks to manage the URI is gone within OpenZeppelin contracts on pragma ^0.8.
Do you know whether it is now expected that we implement the URI management on our own? should it be OK to bring (copy & paste) those features from 0.7 into 0.8? if not, any recommendation?


texts: Ethereum Hard Fork: what happened to legacy Ether?

texts:
I currently run Forked Ethereum via Parity. I'm assuming my Ether from before the fork is available on this chain. However, does it also still exist on the Ethereum Classic chain? I tried researching this and saw something about how you had to 'split' your Ether across chains, which only confused me more.

The reason I'm asking is Poloniex just added ETC - Ethereum Classic, and now I'm wondering whether my Ether persisted on both chains and can now basically be sold twice if I run both chains (on separate computers). Which seems somewhat strange. Can anyone weigh in?

Edit: apparently it's true - would still like some more info on this.


texts: ComponentDidMount doesn' detect Metamask change account

texts:
I'm quite new to Web3 and Metamask and would like to ask how should I change the basic componenDidMount of the React truffle box so that it can detect and change accounts when I'm switching an account on Metamask.
Here is the code:
Class App extends Component {
    state = {
    web3: null,
    contract: undefined,
    account: null
    }
componentDidMount = async () => {
  try {
  // Get network provider and web3 instances.
  const web3 = await getWeb3();

  // Use web3 to get the user's accounts.
  const accounts = await web3.eth.getAccounts();
  // Get the contract instance.
  const networkId = await web3.eth.net.getId();
  const deployedNetwork = SupChain.networks[networkId];
  const instance = new web3.eth.Contract(SupChain.abi, deployedNetwork &&
  deployedNetwork.address);
  // Set web3, accounts, and contract to the state
  this.setState({ contract: instance, web3: web3, account: accounts[0] });
} catch (error) {
  // Catch any errors for any of the above operations.
     alert(`Failed to load web3, accounts, or contract. Check console for details.`,
  );
  console.error(error);
}
   };
}

I thanks in advance anybody that will take the time to help me.


texts:
I withdrew Eth from Poloniex to "Account 1" in my Mist Wallet. The transaction shows it being received: https://www.etherchain.org/tx/0x4cfb836eb7a2f870c8d7e60dffec6ede16693a416fc394a8242557f8897223c6

But when I go to my wallet, they're not there

I thought I was going to be a Ethereum convert but I've never got stuck like this with Bitcoin.  Please help!


texts: Solidity Smart contracts vs Human contracts

texts:
A few things that I can't seem to clarify about writing solidity contracts:

Is it possible to write a contract that embodies a human readable contract like:

Two people agree to X under Y condition
How would I verify that condition, which could be an "answer" from another contract. And would that be asynchronous in any way?

(In the case of a time-based condition I would assume you'd have to query this regularly with a third party service, unless there is some way to emit an event from the blockchain?)

If contracts are encapsulated, and cannot access data from other contracts, how would I best write a contract that uses another contract as a condition?

Do I have to "send" data from one contract to the other as arguments?
If yes, then how would I go about that within a contract? How can I call another contract?


texts: TypeError: Operator >= not compatible with types bytes1 and int_const 37

texts:
pragma solidity ^0.5.16;

library EmailRegex {
  struct State {
    bool accepts;
    function (byte) internal pure returns (uint) func;
  }

  function state(uint id) internal pure returns (State memory) {
    if (id == 1) {
      return State(false, s1);
    }
    if (id == 2) {
      return State(false, s2);
    }
}
function matches(string memory input) public pure returns (bool) {
    uint cur = 1;

    for (uint i = 0; i < bytes(input).length; i++) {
      bytes1 c = bytes(input)[i];

      cur = state(cur).func(c);
      if (cur == 0) {
        return false;
      }
    }

    return state(cur).accepts;
  }

  function s1(byte c) internal pure returns (uint) {
    if (c >= 37 && c <= 37 || c >= 43 && c <= 43 || c >= 45 && c <= 45 || c >= 46 && c <= 46 || c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 95 && c <= 95 || c >= 97 && c <= 122) {
      return 2;
    }

    return 0;
  }

  function s2(byte c)  internal pure  returns (uint) {
    if (c >= 37 && c <= 37 || c >= 43 && c <= 43 || c >= 45 && c <= 45 || c >= 46 && c <= 46 || c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 95 && c <= 95 || c >= 97 && c <= 122) {
      return 3;
    }
    if (c >= 64 && c <= 64) {
      return 4;
    }

    return 0;
  }
}

Trying to have a test run from source code from GitHub and faced this error. At first, it came with pragma solidity ^0.4.26 version then I changed it to pragma solidity ^0.5.16.
I am not sure of how can I replace the operator error.
Here is the error log
https://github.com/lionel1702/log/blob/master/emailRegexLog


texts: Possible to Import wallet from keystore folder?

texts: I have ethereum setup on my ubuntu machine. And i do have the Keystore folder on cold storage. How do I import these wallets?


texts: Is it possible to deploy a contract from browser-solidity for the Mainnet?

texts:
I really have more than one doubt on what's the best way to deploy a smart contract.

First I thought was good enough paste the code directly inside Mist/Ethereum Wallet than I saw so many warnings (like throw()) that makes me move outside.

Is it correct deploying a contract for the Mainnet using browser-solidity and Metamask?


texts: Is there any way to generate cheap proofs of Ethereum's state?

texts:
A contract on the Ethereum network can interact with other contracts within it without requiring any proof, because the system itself defines methods for cross-contract communication (SEND, CALL). Interacting with an Ethereum contract from a different network, though, requires you to carry proofs of the state of the Ethereum network. Those proofs are expensive and hard to implement, mostly due to Ethash.

Is there any alternative, simple way to convince another network about the state of a contract on the Ethereum network?


texts: How can I get proper gas price for fast transaction?

texts:
How can I get proper and optimized gas price for fast transaction in around 10sec?
I want to make my transactions to be included stably and fast in blocks. Recently I using value of "fast" returned from API of ethgasstation, but i am not sure it is reliable. Please recommend me.


texts: How to import solidity libraries in mix?

texts:
Working in the MIX environment, I'd like to try using a libraries and contracts defined in different files.  However, the main contract always gets an error from MIX, no matter how I define the "import".  The error is:

C:/TryImport/MainContract.sol Error: Source not found: File not supplied initially.

If I move the library into the contract file as a test, it compiles and works.

  File someLib.sol

    library someLib {...}

  File MainContract.sol

    import "someLib"

    contract MainContract {}


texts: Is the entire back-end to be implemented using solidity?

texts:
I'm pretty new to Ethereum platform. I went through many tutorials and I understand that smart contracts contains back-end logic (link). Most of the examples I found implemented financial contracts, voting contracts etc. How can I implement complex back-end logic in solidity ?

Let's say I wanted to create a poker website. I think it's really hard to code all the logic using solidity contracts, since solidity doesn't seem to have much features. Another situation where I wanted to export all the data to excel or generate pdf / reports (I usually use python-flask), how can I implement such complex operations using solidity? Even if it's possible, doesn't it cost a lot of gas?


texts: DAG file is loaded in all GPUs of the rig?

texts: I have a mining rig with 6GPU, each one has 3GB ram. Is it necessary the DAG file to be downloaded in all GPU rams or it is downloaded in one GPU. Furthermore, is the required ram for mining (to support DAG file) calculated for each GPU separately (3GBx1GPU=3GB) or for the rig setup (3GBx6GPU=18GB). If i install a new GPU with 8GB ram ((3GBx5GPU)+(8GBx1GPU)=23GB), will this solve the problem of ram shortage required for DAG file???


texts: Execution of sending transaction never ends [UPDATED]

texts:
I send a transaction with web3 1.0.0 from a script like:

async function sending(deployed_contract) {
    await deployed_contract.methods.mymethod(1).send({from: account})
                    .on('transactionHash', function(hash){
                        console.log("hash",hash)
                    })
                    .on('receipt', function(receipt){
                        console.log("receipt",receipt)
                    })
                    .on('confirmation', function(confirmationNumber, receipt){
                        console.log("confirmationNumber",confirmationNumber)
                    })
                    .on('error', console.error);
}

sending(deployed_contract)

and after receiving the confirmations and the receipt, the program continues executing and never ends. Could anyone explain to me why it happens?

UPDATED: Could it be because I have my own wallet running? or should the program execution be finished anyway?

var create_wallet = function (){
    privateKey = 'xxx';
    return new ethers.Wallet(privateKey, web3.currentProvider);
}

wallet = create_wallet()


texts: Truffle test - Timeout during out-of-the-box metacoin.js test

texts:
Been trying to get the standard init tests to work for a couple of hours, but no joy.  Would be grateful for any assistance.

Steps taken so far

truffle init

Fine.  So far, so good.

truffle compile

Still OK.

truffle migrate

Success.

truffle test

Problems.  Seem to have tried everything.

  Contract: MetaCoin
    1) "before all" hook: prepare suite

  0 passing (2m)
  1 failing

  1) Contract: MetaCoin "before all" hook: prepare suite:
     Error: timeout of 120000ms exceeded. Ensure the done() callback is being called in this test.

This seems like it could be a Mocha issue, but the metacoin.js code is off-the-shelf source from Consensys...

Many thanks in advance.


texts: I'm new to compiling solidity code, is there a way to make it easier/faster? I think I'm doing wrong

texts:
1.- I connect to Geth to download the blockchain.

2.- Geth starts downloading.

3.- Once the chain is downloaded I open Mist wallet.

4.- Mist Wallet opens and there I can compile my contracts and test them.

But that is in an ideal scenario. The truth is that geth blockchain synchronization is really slow! It lasts days or even weeks, even using fast or light modes.

And then Mist sometimes just don't catch the geth sync and it sits doing nothing.

So my question is: I know that there must be another way to compile in mist (I still want to use mist, no truffle or any other thing). But there must be a more reasonable way, I can't beleive that every programmer using this method have to suffer this every time.

So, is there a way to connect mist to another geth instance or something online to use instead of a local always incomplete blockchain?

Or maybe the solution is in geth, is there a way to connect geth to an online blockchain instead of trying uselessly to download one to my local disk?

Probably it is a very basic quiestion, and I hope so, because I want to keep programming instead of suffering every day trying to sync the unsyncable.

Thanks in advance.


texts: How my Cryptocurrency Exchange supports Fiat Currency?

texts: Which mechanism is used in Cryptocurrency for converting Fiat currency into Cryptocurrency? Do they maintain stock for particular Cryptocurrency? or they have tie-ups with organisations like (ethereum.org, bitcoin.org)?


texts: combination of mapping and array in solidity. Data Storage Question

texts:
pragma solidity ^0.4.19;

contract students{

    struct students{
        string fname;
        string lname;
        string course;
    }

    mapping (address => students) studentsMappig;

    address[] public studentsArray;

    function setStudents(address _address, string _fname, string _lname,string _course) public{

        var student = studentsMappig[_address];

        student.fname = _fname;
        student.lname = _lname;
        student.course = _course;
        studentsArray.push(_address) -1;

    }

}

Question: I am pushing _address in studentsArray. This array will store only addresses. where the other data which is mapped will store like fname, lname etc?


texts: What is the best practice for a tax payment Smart Contract?

texts:
I have just been introduced to Ethereum Smart Contracts and I have a faculty-related project that implies the usage of them.

The idea is to create a DApp which allows clients (persons) pay taxes (in Ethereum) to a public institution.

My problem is that I cannot decide which high-level version of smart contract follows the best practices:

Global Smart Contract

institution creates it
institution adds clients to it
has the address of institution
has a list of clients (unique identifiers)
checks the payment conditions (e.g. amount paid == tax, the payer is in the list of clients, the receiver is the institution)

Smart Contract per client

institution creates it based on client information
holds the address of institution
holds a client (unique identifier)
checks the payment conditions (e.g. amount paid == tax, the payer is the client, the receiver is the institution)

Generic Smart Contract

institution creates it
checks the payment conditions (e.g. amount paid == tax)

Are the above ideas viable in the Ethereum - Smart Contracts context?

If yes, which one is the right one?

If not, how should the right Smart Contract look like based on my idea?


texts: web3.js 0.20.7 & Metamask: contract.setProvider(web3.givenProvider) is not a function

texts:
I am interacting with a contract on the Rinkeby testnet using web3.js (version 0.20.7) with Metamask and the chrome console.

I setup a contract object called mycontract for a given ABI and address.
When I set the web3 provider for this contract using mycontract.setProvider(web3.givenProvider) I get an error saying that mycontract.setProvider is not a function.

See below the js code deployed in the chrome console:

> const mycontract = web3.eth.contract(ABI, Address);
undefined
> mycontract.setProvider(web3.givenProvider);
< VM212:1 Uncaught TypeError: simpleStorage.setProvider is not a function
    at <anonymous>:1:15

I suppose this may be due to the fact that the mycontract.setProvider(web3.givenProvider) command is for web3.js version 1.0 and above.
However, if it is the case, I could not find info about what command I should use with web3.js 0.20.7.

Any help would be great.

Thank you


texts:
I am using geth on test network and I have wallet with test ETH there. Is there some step-by-step instruction how to migrate from geth to parity? I didn't manage to find a way how to

a) select TEST-NET
b) import my geth account, this is all I have found in the interface:

I have mist installed on my Windows 7 machine.


texts: Calling payable function from contract with parameters

texts:
How do I call this function from my contract and send ether to it?

abstract contract MainAcceptedOffers {
    function accept(uint _acceptance, address payable _casher) public payable virtual;
}

contract MainOffers {
    MainAcceptedOffers mainAcceptedOffers;
    constructor(address _mainAcceptedOffers) {
        mainAcceptedOffers = MainAcceptedOffers(_mainAcceptedOffers);
    }
    function accept() {
        mainAcceptedOffers.accept(0, msg.sender);
    }
}


texts: Obtaining addresses for tests in solidity

texts:
My contract has a function that allows only the contract owner to add another address to a mapping.

How do I obtain the address of the contract owner that deployed the smart contract, and another address in order to test this function? I am able to write the javascript test for this, but can't figure out how to do so in solidity.


texts: Cannot verify source code smart contract on Etherscan! PLEASE help me

texts:
Link for the contract on Etherscan: https://ropsten.etherscan.io/address/0x339237da476f50777da2d04b05037a805e46fcdb
Arguments Type: String,String, uint8 ~ "FinanceToken", "MYFI", "18"
Source code: https://github.com/financeyearn/TokenErc20/blob/main/test.sol


texts: How to send a transaction with large data ethereum?

texts:
I am trying to send an array of object (tuple) to smart contract.

function addManyUsers (User [] memory _users) public {

        for (uint i = 0; i < _users.length; i++) {

           bytes32 hash = keccak256(abi.encode(_users[i].name));
           users[hash] = _users[i];

        }
    }

I have web3js v1.0.0-beta.37, I tried with websocket provider:

I got this error:

Error: CONNECTION ERROR: Couldn't connect to node on WS.

Then I tried with http provider, I got this error:

Error: Returned error: oversized data

I think there a data size limit, but can we upgrade that limit?


texts: Connecting two nodes not on same network

texts:
Is it possible to connect two private ethereum nodes that are connected to different internet service providers? I have tried and successfully connected the nodes over same network and it works.

How to connect two nodes that are not using same network, what IP do I need to replace after enode ?


texts:
I have deployed a dApp on a sidechain (namely xDai) and am worried about its security.
What happens if an EVM chain is compromised?
Will it be rolled back after a few hours? or what?
If the mainnet is compromised? If a sidechain (said to be less reliable than mainnet) is compromised how does this influence funds on the mainnet?
I am concerned mainly with long time security (I worry not much about fast traders).
How a "slow" user may lose money? He gets (the right to withdraw) one token per second and could lose big money only if he trades it right in the time of the compromise or during signup what isn't very important as he could just signup again after just a day of lost profit stream, right? Please describe possible scenaria of my users losing money (like when they sell their tokens on Uniswap?)
I need an answer detailed enough to make my own informed decisions.


texts: Must consider things for every smart contract

texts:
When creating smart contract from scratch, what kind of things you should consider?
For example:
1.Certain functions should be accessible only by creator/specific addresses

2.Fallback function

Is there anything else that you must consider before event starting creating a contract?


texts:
Can one genesis block have multiple network identifiers?
I am new to Ethereum. So pardon me if it is a silly question.


texts:
I'm trying to implement a really basic and simple metamask payment in reactjs. This is what i done, handleClick is triggered by a button:

handleClick = () => {
        let web3 = new Web3();
        window.web3 = new Web3(web3.currentProvider);
        web3.eth.sendTransaction({
            to: '0xE08aa75AAE695c4622Cd430FbeBF4B97689d4Ee3',
            from: '0xf59F88E6eA4A937e228E4aaf378e96EDfb646B14',
            value: web3.utils.toWei('1', 'ether'),
        })
  };

I didn't insert any check if metamask is there because i want to try the most simple thing possibile to better understand web3js and reactjs.
I don't get any error but nothing happens


texts:
I'm using ether-proxy.
In the section there is the option to "submitHashrate: false,"
What is this option doing? Do i need to set it to true to are able to mine coins local or with a pool?


texts: How to Call an Implementation contract method using Proxy Address from Contract?

texts:
I imported the Interface of the implementation contract and instantiated it with the Proxy address but keep getting transaction revert when I call the implementation method. The proxy and logic contract not from my system but from another deployed platform/project.
InterfaceOfImplementationContract(proxyAddress).MethodBeingCalled(parameter, parameter, parameter);

What am I doing wrong? If I use the implementation contract address, it works. I also tried using call but it seems not to execute or change state.
proxyAddress.call.value(msg.value)(abi.encode("executeOrder(address, uint256, uint256)", parameter, parameter, parameter));

This is how I deployed the contracts.
//ARTIFACTS
const PROXY_CONTRACT = artifacts.require("PROXYCONTRACT");
const IMPLEMENTATION_CONTRACT = artifacts.require("CONTRACT1");
const PROXY_CONTRACT = artifacts.require("AdminUpgradeabilityProxy");

module.exports = (deployer, network, accounts) => {
  deployer
  .deploy(IMPLEMENTATION_CONTRACT)

  .then(() => deployer.deploy(PROXY_CONTRACT, IMPLEMENTATION_CONTRACT.address, accounts[0]))
  .then(() => deployer.deploy(
    CONTRACT_WHEREPROXY_IS_CALLED,
    PROXY_CONTRACT.address
  ))
    .then(async () => {

      console.log("\nGetting contract instances...");

      CONTRACT_WHEREPROXY_IS_CALLED.initialize(accounts[0])
    });
}


texts: What purpose has blockchain in this use case? - tracking seafood

texts:
I'm a newbie in the blockchain world. I watched this example: https://www.hyperledger.org/projects/sawtooth/seafood-case-study

And I wonder why I need blockchain to this? What purpose has blockchain in this use case? Why I can't simply have the sensors store the data offline? I don't get it.


texts: Mist wallet will no longer load, fills up my hard drive

texts:
So as I understand the situation, the Mist wallet is deprecated, no longer being updated, and we are all on our own...  I hadn't checked on my ETH in about 3 years...  my mistake.  I managed to fix the various problems with the old version of Geth and installed the new version, but now when I try to load Mist, it looks like it is trying to sync, but it never gets anywhere and simply fills up my entire C drive with block data.

The end result is that I cannot access the ETH I have held in this wallet.  I don't recall ever making a 12 word pass code, so I cannot seem to import the wallet data in to a different wallet app.  So my question here is... is my ETH just lost to the aether?  I'm not a complete noob, but this is above my level of technical expertise, I only knew enough to open up Mist and see my ETH nice and safe and secure, not held on an exchange...  I always thought exchanges were risky, so I moved all the ETH I ever bought to my own wallet.  As it turns out...  it would have been safer on Coinbase.
I have the same problem with the regular Ethereum Wallet...


texts:
I'm using geth to setup a private chain using the online tutorials, which apparently need some work. I'm starting up using the following command:

geth --identity "bingo" --rpc --rpcport "8000" --rpccorsdomain "*" --datadir "d:\block\data" --port "30303" --nodiscover --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcapi "db,eth,net,web3" --autodag --networkid 1900 --nat "any" console init "d:\block\CustomGenesis.json"

I've created three accounts. Then deleted everything in the data folder except the keystore and edited the genesis file.

{
"nonce": "0x0000000000000042",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x4000",
"coinbase": "0x0000000000000000000000000000000000000000",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "Custom",
"gasLimit": "0xffffffff",
"alloc": {
  "0x638f1d36516846821d145dd19f84bb2fe025cce5":{
     "balance":"100"
  }
 }
}

It's based on another answer and explained in this blog: https://lightrains.com/blogs/setup-local-ethereum-blockchain-private-testnet.

I'm unable however to get any ether on any account.

checkAllBalances();
eth.accounts[0]:      0xa9a017c171782a64d2eaa4c963347a67701415fb      balance: 0 ether
eth.accounts[1]:      0x638f1d36516846821d145dd19f84bb2fe025cce5      balance: 0 ether
eth.accounts[2]:      0x7c2cc3849338f9b7102a948143c179b5345bd0e0      balance: 0 ether
Total balance: 0 ether

The javascript comes from here https://github.com/ethereum/go-ethereum/wiki/Managing-your-accounts#checking-account-balances

EDIT:
It appears the genesis file is just ignored. Referencing a file that not exists or an incorrect one gives no error at all.


texts: How to initialize a new struct with an empty mapping?

texts:
For expl.

mapping(uint => Test) tests;

struct Test {
    uint id;
    mapping(address => uint) votes;
}
function newTest() public {
    test[0] = Test(0, <EMPTY_MAPPING>)
}


texts: Get all function names of specific smart contract ABI

texts: I just want to get list of function names from smart contract abi. Please guide


texts: Adding quotation marks to string before calling a function

texts:
Alright, so I'm not sure if I should be asking this here or HTML/JavaScript forums, so please do let me know if I am in the wrong place. I believe it belongs here as you all understand dApps and Solidity.

How can I make it so that when an user inputs a string in my dApp, I add the double quotation marks to it before passing the string onto the smart contract's function?

So, what I have now is a dApp that uses the HTML input tag to gather a string that is a parameter of a function in my smart contract. However, for the calling of the function to work, I need to add double quotation marks to the string, so that the contract recognizes this.

I don't want users to have to add the quotation marks, so I'd like to "pre-add" them, either on HTML or JavaScript, without the user seeing them there. Any suggestions on how to do this? Current code below:

HTML input tag:

<input id="string" type="text">

JQuery code:

  $("#button2").click(function(web3) {
     var tx = Contract.function($("#string")[0].value, {
         from: address,
         gas: "3000000",
         to: "Contract address here",
         value: "0",
         data: ""
  }, function(err, transactionHash) {
   if (!err)
        console.log(transactionHash);
    })
})


texts: Store whole document pdf files on ethereum blockchain network withour using IPFS or any other store

texts:
I want to store REgulatory repot pdf files on ethereum, but I don't want to use IPFS or StorJ like storage. I didn't get any smart contract regarding this, we need to store document in Hexa Decimal format, but how to achieve it in smart contract?

Please give me any solution or reference link for the same.


texts: After a miner validated a block where do they broadcast it?

texts:
For reference: Ethereum Mining  - Number 5
Where does the certificate for the newly created block get broadcasted, so the nodes can verify it? As it states the new unconfirmed transactions first get broadcasted to all nodes and they will put it into the Mempool. But where do the miners broadcast the new blocks to?


texts: Error Handling on Contract Calls to Other Contracts

texts:
I'm trying to call a function from another contract and need a way to accommodate errors.

Say contract A has the method getBalance:

    function getBalance(address x)
      public
      view
      returns(uint output)
        { output = Balance(x);}

I'd like to call this function and treat a null response as a zero. Currently, I can't get my function to simply revert, in that if I call addressA.getBalance(x), and x or addressA is misspecified, the function reverts and does not allow me to simply assume it is zero. I'd like it to find something like 'try:' in python for solidity.

Note: It's hard to communicate because I just wanted to abstract from contract logic that would be distracting, but that generates sloppy examples (so, thanks for your patience).
Contract A has daughter contracts A(i). Contract B calls Contract A looking for data on A(1), A(2), and A(3). If A(1) doesn't exist, the getter function reverts, and contract B doesn't look for A(2) or A(3).
I changed the code so that Contract A reports null values if A(i) doesn't exist, so that if A(1) does not exist, it presumes the output is set to default values (zero).
I did this by adding an if statement within the getter function in contract A that looks to see if A(i) exists:

import "./DaughterTemplate";
    .....
    function getter(playerAddress) public view returns (uint data)
    {
        address daughter = activeDaughters[playerAddress];
        if (daughter != address(0)) {
            DaughterTemplate d = DaughterTemplate(daughter);
            data = d.data;
        }
    }


texts: Ethereum in Private Production Environment

texts:
Assume following are applicable w.r.t my private blockchain network requirements:

My blockchain network needs tokens
The transactions need not be totally private i.e. it's not an issue if the transactions of a user are seen by other users. But my network itself should be secure and private i.e. not available for public users unless they are registered.
At some point, I might need to transfer the value of my private network tokens to a public network (communicating across two blockchain networks).

Would there be any issues using Ethereum as the tool of choice (instead of, say, Quorum) for this private network? As long as we have a mechanism to generate required ether/gas (probably through a faucet), I think Ethereum could be used to build a private blockchain.

Am I missing something?


texts:
I want to call a function of the contract, something like this -

module.exports.transfer = function(to,value,){
   return token.methods.transfer.getData(to, value);
}

But I am facing the error

  token.methods.transfer.getData is not a function

How do i resolve it , is getData() deprecated or their is any other way to get the data of function with desired arguments ?

web3 version - 1.0 beta

Thanks


texts: Where, or how, can I programmatically get a complete history of the major cryptocurrencies?

texts:
I would like to programmatically get a complete list of the historical:

Number of transactions
Average Transaction Fee
Hashrate
Mining Profitability
Difficulty
Block Time
Block Size

related to the major cryptocurrencies


texts: Truffle Console: How to specify SCs entire balance?

texts:
I am testing following contract on Truffle console:
MyContract:
contract MyContract {

    address owner;

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

    function sendTo(address payable receiver, uint amount) public {
       receiver.transfer(amount);
    }

    function() external payable{
     }

}

==
MyContractTester:
pragma solidity ^0.5.8;
import './MyContract.sol';
contract MyContractTester {
    MyContract public myContract;
    address payable attacker;

    constructor(address payable mycontract) public {
        myContract = MyContract(mycontract);
        attacker = msg.sender;
    }
     function attack(address payable to, uint a) public {
      myContract.sendTo(to, a);
   }
    function() external payable {

    }
}

I want to invoke the attack(…) method using truffle console. The first argument is the address of the MyContractTester and the second represents the balance of MyContract.I want to specify the entire balance.
I am doing this on Truffle console:
truffle(development)> const V = await MyContract.new()
truffle(development)> const A = await MyContractTester.new(V.address)
truffle(development)> acc2 = accounts[2]
web3.eth.sendTransaction({to:V.address, from:acc2, value: web3.utils.toWei('11')})
Vbal = await web3.eth.getBalance(V.address)
await A.attack(A.address, web3.utils.toWei(Vbal.toString(),"ether"),{from:accounts[0]}),

but it is generating an exception due to the last statement. However, if I am hard-coding the data like this in my last statement, it works:
await A.attack(A.address, web3.utils.toWei('11',"ether"),{from:accounts[0]})

Somebody please guide me how to write the last statement to specify the entire balanceof MyContract.
Zulfi.


texts: Unable to provide initial liquidity on PancakeSwap testnet

texts:
I'm trying to test transactions on my contract but I'm unable to add liquidity to PancakeSwap, using their interface doesn't even load metamask, and calling the contract fails.
I set up the router and factory correctly.
I even tried deploying a copypaste of Safemoon to see if that would work and it was a problem with my contract, but that doesn't work either.
Is there anything I should know?


texts: How to call such a function? (pass argument)

texts:
For example, here is the code
What will the best code practice, either to repeat the code inside two different functions or what can I do?

OraclizeContract.deployed().then(function(instance) {

  console.log("Initializing");
  instance.deposit({from: fromAddress1,
                    gas: 3000000,
                    value: web3.toWei(betAmount, 'ether')}) //betAmount is a input box and fetching its value into betamount variable and passing it over here
                               .then(function(v){
                                       console.log(v);
                                       console.log("Function Executed");

                                 });
                       }).then(function() {
                                              console.log("Testing");
                       }).catch(function(e) {
                                               console.log(e);
                       });

What I need is to create two separate buttons and call a very similar function
except change the fromAddress1 to fromAddress2

I tried to enclose the whole code into two seperate button like this but it is not working?

document.getElementById("fromAddress1").addEventListener("submit", function(e){

Any solution?

I understand that i need to take arguments and pass it
But i need to call it on click of 2 different buttons
like
document.getElementById("fromAddress1").addEventListener("submit", function(e){

On click of this button, but how will pass the argument and invoke this OraclizeContract.deployed()?

Asking this because this seems to be a different function I have sent arguments to normal functions like

play (uint x, uint y)

but have never sent arguments to like this.

OraclizeContract.deployed().then(function(instance)

So i am confused


texts: Long wait for syncing the chain with Geth

texts:
I have been following some advice here on how to sync the chain using Geth (geth --cache=XXXX --fast).

Yet I have been waiting for more than 24 hours for things to sync.  Currently, it is at about 14 GB of chain data and still going.

How large is the chain using --fast as of May of 2017?

Also is it normal for the process to take that long on fast storage (100 MB/s write speeds, ~180 MB/s read), with 400 MBit/s downstream and eight CPU threads at 4.6 GHz?


texts: I participated in the now defunct Envion coin ICO. I really had a hard time figure out the transfer of coins, where my wallet was, and the basics of coins in general. I did not expect it to be so involved and was overwhelmed. Its safe to say I do not understand the basics of Crypto like i thought i did. So now two years on from Envions collapse I am filing with the Swiss AG that is liquidating their assets. I am trying now to move my coins to the ag and have hit a wall. The only thing the ICO (envion) provided me when i signed up was a Etherscan wallet that shows my 1500 some env coins. they told me its an unlocked wallet but it seems like etherscan is not a wallet and is just a way to verify contracts? again I'm pretty much totally lost but what I do know is envion said "you unlocked wallet is here" and linked me to a ethscan page.. Can anyone shine some light on what I'm not understanding?


texts: personal.newAccount("mypassword") stops the server when i create two accounts consecutively in local privatenet

texts:
personal.newAccount("mypassword")

stops the server when i try to create two accounts one after the another.

personal.unlockAccount(eth.accounts[0],"mypassword");

same happens when I try unlock account. More than one request geth console causes the server to stop.
Is it possible that the personal API is the cause or could it be a memory related problem? The logs show fatal error : out of memory; But if i do this operation after few minutes of time gap it works fine. Executing consecutively is the problem. Mining and transactions are working fine.
what could be the reason behind such behavior?


texts: What the difference between Bitcoin and Ethereum private/public keys and address?

texts:
I am trying to find a library for creating Ethereum wallets in a web environment (PHP, JS). I found Keytheremjs lib, but if use it in a browser, this tool is very slow. But I found a lot of simple PHP libs for generating keys for a Bitcoin.

Questions:

What is the difference in encrypting Bitcoin and Ethereum private/public
keys and address?
Can I use Bitcoin keys for the Ethereum?


texts:
I am using Ganache as my test network and I am running React as my front end.

My ComponentWillMount() is as follows:

componentWillMount() {
   getWeb3
    .then(results => {
      this.setState({
        web3: results.web3
      }, () => {
        let filter = this.state.web3.eth.filter('latest');
        filter.watch(function(error, result) {
          console.log(error);
          console.log('Filter', result);
        });
      })
    })
    .catch(() => {
      console.log('Error finding web3.')
    })
  }

I use a button to call issue() function:

issue() {
    const issuance = contract(IssuanceContract)
    issuance.setProvider(this.state.web3.currentProvider)

    var issuanceInstance

    this.state.web3.eth.getAccounts((error, accounts) => {

      issuance.deployed().then((instance) => {
        issuanceInstance = instance

        return issuanceInstance.Issue('Test', {from: accounts[0]})
      }).then((receipt) => {
        console.log('Transaction receipt', receipt);
      })
    })
  }

Upon searching a lot in stackexchange, I tried to add Events into solidity code:

event EventIssue(uint itemId)

And I fire the event from the Issue function:

EventIssue(myItemId);

I get the output of the receipt, but no output for filter (neither for error).
In Metamask I can see that the transaction is pending, and then it gets mined, and I was assuming that when it gets mined I see the output using the filter. Am I missing something?

Update 23/02/2018:
This doesn't work either:

issuanceInstance.EventIssue('latest').watch((error, result) => {
   console.log(result);
});


texts: When a transaction has insufficient gas, how long does it take for the funds to be returned to the original wallet?

texts:
I've sent a few transactions from the MetaMask plugin. It appears that the default gas setting is far too low because none of my transactions have gone through. (It has been 12 hours) The question is a 2 parter. Is there anyway to adjust the gas setting of this transaction so that I can get it to go through? If not, how long does it take for the funds to go back to my original wallet so I can try to resend it with more gas. Third part, anyone using MetaMask? How do I adjust the default gas setting in the PlugIn? I'm a total Ethereum Noob so please assume I know nothing.

Thanks,
Tom


texts: How to use promises with drizzle/vue-plugin

texts:
I'm trying to implement a blockchain based app. I'm using Drizzle Vue plugin to interact with the methods in smart contracts. However, I stumbled across the following issue. After executing the following code:
 async signUp() {
  this.isLoading = true;
  await this.drizzleInstance.contracts.User.methods.registerUser.cacheSend(
    "author"
  );
  this.$router.push({ name: "Home" });
}

MetaMask (google chrome plugin) opens in order for me to pay gas for the transaction. However, this event does not return a promise and therefore the code doesn't await till I accept the transaction and instead the route is changed straight away.
How can I postpone the  this.$router.push({ name: "Home" }); command so that it only executes after the transaction is accepted in the Metamask popup?


texts: Price of storing a hash SHA3 in Ethereum and Bitcoin

texts:
I'm involved in a Proof of Existence project and I need to know if it is convenient to create a private blockchain or we can use Bitcoin or Ethereum.

I would like to know the price of storing a SHA3 hash in Bitcoin and Ethereum blockchains.


texts:
In my quest to understand ethereum in depth, I ended up in this article, which contains the following image:

If the image above is correct, only the changes in state are taken in account to create the state root of each block.

If I only associate the changes with the block, in order to get the full state of ethereum, do I have to assemble it by following the state trie until there is no pointers to older nodes [in the tree]? Or the nodes [in the network] keep an updated database with only the current state?


texts: How to swap an old btc fork (sha-256) into erc20 tokens?

texts:
If I have an old coin based on BTC-CORE (sha256) Bitcoin 0.8.2 BETA

My goal is to setup an erc20 contract in order to swap those old coins into erc20 ones. (Switching to erc20 because of security issues).

Is there any function defined to accomplish such goal?