/web3playground

Web3 & Smart contracts Playground

Primary LanguageJavaScript

Web3 Playground

Test your contracts by creating your custom code snippets. Web3 1.X.X ready to be used.

Table of content

How it works

  • Paste the address of the contract you want to try.
  • Choose a name for the variable.
  • If the contract is upgradeable by using the proxy pattern, select the checkbox.
  • Code.

Screen Shot 2019-11-24 at 19 48 21

Examples

  • Get the name of a contract:

    async function main() {
      const name = await contract.methods.name().call()
      return name
    }
  • Get NFTs owners:

    async function main() {
      const tokenIds = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
      const owners = []
    
      for (let i = 0; i < tokenIds.length; i++) {
        const owner = await contract.methods.ownerOf(i).call()
        owners.push(owner)
      }
    
      return owners
    }
  • Transfer tokens:

    async function main() {
      const to = '0x...'
      const value = 1e18
    
      const txHash = await contract.methods.transfer(to, value).send()
    
      return txHash
    }
  • Get ETH balance:

    async function main() {
      const user = '0x..'
      const ethBalance = await web3.eth.getBalance(user)
      return ethBalance
    }

Methods are typed!!

Screen Shot 2019-11-24 at 19 42 47

FAQ

  • Is only javascript available?

    Yes, the snippet runs in the browser.

  • Which proxy implementations are supported?

    So far, the ones detected by topics as:

    • Event Upgrade(address,bytes) = 0xe74baeef5988edac1159d9177ca52f0f3d68f624a1996f77467eb3ebfb316537.

    • Event Upgraded(address): 0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b.

    • EIP-1167 MinimalProxy.

    • Implementation made by OpenZeppelin. Searching for the storage slot 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3

  • Which chains are supported?

    Every RCP call is made to the network selected in your provider.

  • Which wallets are supported?

    I 've tested it with a few. Also mobile. If you have a wallet and it is not supported, please let me know and I will add it.

  • Can I refresh the browser?

    Yes! Contracts and code are stored at localstorage if any.

  • Can I contribute?

    Yes! please, It will be awesome.

Next

  • Share code snippets by hosting them on IPFS

Donate ❤️