Most Popular

1500 questions
10
votes
2 answers

How to ask the metamask user to switch its network?

Some web3 enabled websites ask you to switch your network on metamask. How can I do so? Some other websites also allow you to add a network you don't have (for example https://chainlist.org/). I would like to do it too. Example: I am using react…
Th0rgal
  • 245
  • 1
  • 2
  • 11
10
votes
4 answers

What is the correct way to access public variable from contract in Truffle: then or standard callback?

There are some similar posts to this but none seem to be able to solve my problem. I have a contract deployed with Truffle running with testrpc. I want to access the value of a public uint variable named gameStatus defined in the deployed contract…
Carlos G. Oliver
  • 231
  • 1
  • 2
  • 6
10
votes
1 answer

Inside a smart contract, is it possible to get latest mined block's number and its hash?

As following answer for How can I find out what the highest block is? guided: we can get the latest mined block's number and its hash inside geth as follows. > eth.syncing.currentBlock 569367 >…
alper
  • 8,395
  • 11
  • 63
  • 152
10
votes
2 answers

access struct from mapping in a different contract

I want to access / modify data from a contract from another contract. If you could help me understand the error that would be great! I get the following error: Untitled1:33:8: Error: Indexed expression has to be a type, mapping or array >(is…
Victor
  • 101
  • 1
  • 3
10
votes
2 answers

How to properly implement a ContractURI for on-chain NFTs

I am trying to implement contract-level metadata for an NFT collection on OpenSea, However, if I do so with the following code, the contract's metadata won't update on the OpenSea collections' page, nor will it update the description of the contract…
Martijn Vissers
  • 308
  • 2
  • 12
10
votes
1 answer

Uniswap V2 calculate quantity tradable at target execution price in Solidity?

Let's say the instantaneous price of ETH/USDT pair is 2000. If I trade a lot of ETH for USDT, there could be a lot of slippage, and my trade might fulfill at an average execution price of 1950 USDT per ETH. Let's say I'm ok with trading at 1950…
David Callanan
  • 792
  • 6
  • 20
10
votes
1 answer

Creating multiple contracts or Single contract with struct

I would like to understand which of the following patterns is better. Say my use case is to have two types of users in my platform buyer and seller for a product, with regard to my architecture Im left with two options. To have one contract which…
Mighty Proton
  • 307
  • 2
  • 8
10
votes
2 answers

Raw transaction data in Go

I would like to generate raw transactions in golang without any go binding and I'm wondering if there is library to dynamically encode my argument parameter using go? https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI Using this resource it…
rawEth
  • 101
  • 1
  • 3
10
votes
4 answers

Unable to make greeter contract

For the past 7 days I've been trying to make the greeter contract, I've been through 4 different physical computers in 2 different locations and have tried multiple different ways on 3 different operating systems. I've attempted all the tries above…
冬賀雪花
  • 309
  • 1
  • 4
10
votes
5 answers

How do I use BigNumber values in Hardhat tests?

I'm using Hardhat with TypeScript/Ethers/Chai. I can't find a way to test BigNumber values. For example, expect(someBigNumber).to.be.equal.to.(otherBigNumber) will (understandably) throw an error like this one: AssertionError: expected…
frostpad
  • 201
  • 1
  • 2
  • 5
10
votes
2 answers

Solidity Browser - Issue with every example => Error: Type "address" not supported for state variable

I am very new to blockchain and Ethereum. I want to get started with a BaaS cloud service and develop / execute some smart contracts. I successfully set up the Azure Ethereum template…
Kai Wähner
  • 363
  • 2
  • 11
10
votes
3 answers

How to fix "TypeError: Cannot read property 'sendTransaction' of null" when deploying a contract on Ropsten with hardHat?

I am getting this error: TypeError: Cannot read property 'sendTransaction' of null when running this command: $ npx hardhat run scripts/deploy.js --network ropsten with HardHat on Ropsten network. This is my deploy.js (which is the one provided by…
Andrea D_
  • 231
  • 1
  • 2
  • 8
10
votes
1 answer

What about illegal smart contracts?

Trying to get a friend excited about smart contracts I referred him to an ethereum pyramid scheme as an easy to understand example but he only pointed out that all pyramid schemes are illegal. How should one counter that concern? If this is the…
hcvst
  • 2,018
  • 2
  • 21
  • 24
9
votes
2 answers

Running Mist with INFURA

Is it possible to run the Mist browser with an external ETH client like INFURA? Yes, I understand this may not be the decentralized paradise we want to get to, but I'd just be happy to run a browser for now w/o having to download the entire…
ronme
  • 1,035
  • 1
  • 9
  • 18
9
votes
2 answers

What is the best way to handle multiple NFTs of the same collection in ERC1155?

I'm learning ERC1155, and I'm a bit confused. This is OpenZeppelin's example of an ERC1155 Contract: They state that Thor's Hammer is an NFT (because only 1 was minted), while Gold is Fungible. Therefore this example contains several Fungible…
1 2 3
99
100