New answers tagged

0

If anyone is looking for a JS solution: const Web3 = require('web3') const web3 = new Web3() const elliptic = require('elliptic') const ec = new elliptic.ec('secp256k1') function pubKeyToAddress(compressedPubkey) { let keyPair = ec.keyFromPublic(compressedPubkey, 'hex') // remove '04' then add prefix '0x' let pubkey = '0x' + keyPair.getPublic(false, '...


2

For 1 you may use web3.eth.getCode(address) function of Web3 API. For contract addresses it returns contract byte code, while for non-contract addresses it returns something like "0x". For 3 it depends on what "public" means for you. If you mean whether smart contract has verified source code published at Etherscan.io, then you may use either API call to ...


2

It is unclear what layer you want to find out this information on (on-chain or off-chain). In general: Is an address a smart contract? This can be checked by seeing if there is associated code at the address. Is this smart contract ERC20 or ERC721 token? Off-chain, you can check this by observing the contract on Etherscan. There are also interfaces ...


0

I didn't see where web3.eth.getAccounts() is used in your code, but this is javascript promise and you might wanna use it this way to get the accounts: web3.eth.getAccounts(function(error, accounts) { if(error) { console.log(error); } else { console.log(accounts); } });


1

You can simply check val as a uint. Your code would look as follows: function airdrop(uint val) public payable { require(airdrop == true); if (val == 1){ msg.sender.transfer(1 ether); airdrop = false; } }


1

Only an EOA can sign and send a transaction. It can be addressed to a contract in which case the contracts functions must run. A contract's functions can send messages and/or value to other contracts in which case they also run, or to an EOA which just receives because it has no code. All of this happens approximately instantaneously (after mining) ...


2

It's not so much about whether a smart contract has a private key or not; it's more about the fact that smart contracts can't initiate a transaction. All transactions are started by an EOA to either a smart contract or to another EOA. If a transaction is sent to a contract the contract may include functionality to call another address within the same ...


1

The smart contract can only send a transaction to an EOA if the transaction was initiated by an EOA. Smart contracts cannot initiate a transaction because they do not have a private key and cannot sign a transaction, as you said. When value is being sent from a smart contract to an EOA, what is really happening is an EOA sending a transaction to the network ...


2

Private Key Space: Here are some code examples, based on the elliptic curve secp256k1 used by ethereum, as others have noted in order for the 256-bit key to be valid, it must be smaller than the curve's parameter n which is also a 256-bit value which can be written in hexadecimal format as: 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 ...


0

If you are using blockcypher simply send -1 as the amount.


0

I'm not sure what you need exactly. Uport will be a good alternative if you want to work in mobile browsers as well. But users need to have there mobiles with them to use the dApp. if only to use in PC browsers I recommend Metamask. But with mobile browsers metamask is still in early stage. Check this post. This list might help you as well.


1

Something that may be of interest is https://squarelink.com/ Other than that, metamask is ahead of everyone else as far as I know.


Top 50 recent answers are included