onSubmit(event) {
    event.preventDefault()
    ipfs.files.add(this.state.buffer, (error, result) => {
      if(error) {
        console.error(error)
        return
      }
      this.setState({ ipfsHash: result[0].hash })
      console.log('IPFS Hash', this.state.ipfsHash)
      console.log(`https://ipfs.io/ipfs/${this.state.ipfsHash}`)
    })
    // define asynchronous contract method
    const tokenize = async () => {
      const { accounts, contract } = this.state;
      await contract.methods.mint(accounts[0], `https://ipfs.io/ipfs/${this.state.ipfsHash}`).send({ from: accounts[0] });
    };
    // call contract method
    tokenize()
  }
// obtain the ipfs hash from the buffer created above
obtain the ipfs hash from the buffer created above
obtain the ipfs hash from the buffer created above
onSubmit(event) {
    event.preventDefault()
    ipfs.files.add(this.state.buffer, (error, result) => {
      if(error) {
        console.error(error)
        return
      }
      this.setState({ ipfsHash: result[0].hash })
      console.log('IPFS Hash', this.state.ipfsHash)
      console.log(`https://ipfs.io/ipfs/${this.state.ipfsHash}`)
    })
    const tokenize = async () => {
      const { accounts, contract } = this.state;
      await contract.methods.mint(accounts[0], `https://ipfs.io/ipfs/${this.state.ipfsHash}`).send({ from: accounts[0] });
    };
    tokenize()
  }
onSubmit ( event ) { event . preventDefault ( ) ipfs . files . add ( this . state . buffer , ( error , result ) => { if ( error ) { console . error ( error ) return } this . setState ( { ipfsHash : result [ 0 ] . hash } ) console . log ( 'IPFS Hash' , this . state . ipfsHash ) console . log ( ` ${ this . state . ipfsHash } ` ) } ) const tokenize = async ( ) => { const { accounts , contract } = this . state ; await contract . methods . mint ( accounts [ 0 ] , ` ${ this . state . ipfsHash } ` ) . send ( { from : accounts [ 0 ] } ) ; } ; tokenize ( ) }
obtain the ipfs hash from the buffer created above
obtain the ipfs hash from the buffer created above
// define asynchronous contract method // call contract method