Skip to content

Instantly share code, notes, and snippets.

@merlox
Last active March 21, 2019 12:33
Show Gist options
  • Save merlox/5a4c3b8430834bfff18629689d86ae8a to your computer and use it in GitHub Desktop.
Save merlox/5a4c3b8430834bfff18629689d86ae8a to your computer and use it in GitHub Desktop.
import React from 'react'
import ReactDOM from 'react-dom'
import { MetamaskProvider } from '@0xcert/ethereum-metamask-provider'
import { schema88 } from '@0xcert/conventions'
import { Cert } from '@0xcert/cert'
// Assets Ledgers are groups of tokens that are managed by certain users just like mods in a chat to do what's required
// The Capabilities determine what those mods can do with the assets they are managing
// The Ethereum address that deploys this ledger has full powers to do whatever he wants as the administrator
import { AssetLedger, AssetLedgerCapability } from '@0xcert/ethereum-asset-ledger'
import './index.css'
class Main extends React.Component {
constructor() {
super()
this.state = {
provider: {},
ledger: {},
assets: []
}
}
// Run your desired functions here
async componentDidMount() {
await this.displayBlueprint()
}
// To configure new ERC721 assets
async displayBlueprint() {
const cert = new Cert({
schema: schema88
})
const asset = {
description: 'A lighthouse watercolor picture',
image: 'https://upload.wikimedia.org/wikipedia/commons/a/a3/Taran_Lighthouse_Kalinigrad_Oblast_Tatiana_Yagunova_Watercolor_painting.jpg',
name: 'Lighthouse Watercolor'
}
// The imprint is the hashed proof for our asset
console.log('Imprint', await cert.imprint(asset))
console.log('Expose', await cert.expose(asset, [['name'], ['image']]))
}
render() {
return (
<div>
<h1>ERC721 Art Marketplace</h1>
<p>In this marketplace you can deploy unique ERC721 art pieces to the blockchain with 0xcert.</p>
<div className="assets-container"></div>
<button className="margin-right">Deploy Art Piece</button>
<button>Get Art Pieces</button>
</div>
)
}
}
ReactDOM.render(<Main />, document.querySelector('#root'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment