The Tuli class gives a developer direct read / write access to a specified instance of the Tuli Protocol.
constructor(
signerOrProvider: Signer | Provider,
chainId: number,
mediaAddress?: string,
marketAddress?: string
)
The constructor requires two arguments:
- signerOrProvider
- chainID
The constructor will use the signerOrProvider
to determine if the Tuli Instance is readOnly
or readAndWrite
capable.
If a signer
is passed in then the Tuli instance will be able to invoke both read and write functions.
If only a provider
is passed in then the Tuli instance can only invoke readOnly methods.
The constructor will use the chainID
to look up the officially supported Tuli Protocol addresses and return a Tuli instance connected the protocol
If the chainId does not exist in chainIdToNetworkName
the constructor will raise.
The constructor can optionally accept two parameters to override
the official supported Tuli Protocol addresses. These overrides are particularly useful for development on a local blockchain. The overrides must adhere to a logical XAND
to be valid. Either both overrides must be present or both must be null.
import { Tuli } from '@tulilabs/tdk'
import { Wallet } from 'ethers'
const wallet = Wallet.createRandom()
const tuli = new Tuli(wallet, 1)
const totalSupply = await tuli.fetchTotalMedia()
import { Tuli } from '@tulilabs/tdk'
import { Wallet } from 'ethers'
const wallet = Wallet.createRandom()
const tuli = new Tuli(wallet, 4)
const totalSupply = await tuli.fetchTotalMedia()
When using a local blockchain you must specify overrides for both mediaAddress
and marketAddress
. These should point to the addresses of deployed Tuli Media and Market contracts on your local blockchain.
import { Tuli } from '@tulilabs/tdk'
import { Wallet } from 'ethers'
const wallet = Wallet.createRandom()
const tuli = new Tuli(wallet, 50, mediaAddress, marketAddress)
const totalSupply = await tuli.fetchTotalMedia()
Fetch the contentHash
of a piece of media.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose content hash is being fetched |
Fetch the metadataHash
of a piece of media.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose metadata hash is being fetched |
Fetch the contentURI
of a piece of media.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose content uri is being fetched |
Fetch the metadataURI
of a piece of media.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose metadata uri is being fetched |
Fetch the creator
of a piece of media.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose creator is being fetched |
Fetch the current bidShares
of a piece of media.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose current bid shares are being fetched |
Fetch the current Ask
of a piece of media.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose current ask is being fetched |
Fetch the current Bid
for a bidder on a piece of media.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose metadata uri is being fetched |
bidder | string | The address of the bidder |
Fetch the next permit nonce for an address
Name | Type | Description |
---|---|---|
address | string | The address of the account whose permit nonce is being fetched |
Fetch the next mintWithSig nonce for an address
Name | Type | Description |
---|---|---|
address | string | The address of the account whose mintWithSig nonce is being fetched |
Fetch the balance of an address on an instance of the Tuli Media Contract
Name | Type | Description |
---|---|---|
address | string | The address of the account whose balance is being fetched |
Fetch the owner of a piece of media on an instance of the Tuli Media Contract
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose owner is being fetched |
Fetch the mediaId of the specified owner by index on an instance of the Tuli Media Contract
Name | Type | Description |
---|---|---|
owner | string | The owner address of the media |
index | BigNumberish | The ERC-721 enumerbale index of owner |
Fetch the total amount of non-burned media that has been minted
Name | Type | Description |
---|---|---|
Fetch the mediaId by index
Name | Type | Description |
---|---|---|
index | BigNumberish | The ERC-721 enumerbale index of a piece of media |
Fetch the approved account for the specified media
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose approved address is being fetched |
Fetch if the specified operator is approved for all media owned by the specified owner
Name | Type | Description |
---|---|---|
owner | string | An address on the Tuli Protocol |
operator | string | An address on the Tuli Protocol |
Mint a new piece of cryptomedia.
Name | Type | Description |
---|---|---|
mediaData | MediaData | The data represented by this media, including SHA256 hashes for future integrity checks |
bidShares | BidShares | The percentage of bid fees that should be perpetually rewarded to the creator. |
Mint a new piece of media on behalf of signed message from a creator.
Name | Type | Description |
---|---|---|
creator | BigNumberish | The creator address of the piece of media |
mediaData | MediaData | The data represented by this media, including SHA256 hashes for future integrity checks |
bidShares | BidShares | The percentage of bid fees that should be perpetually rewarded to the creator. |
sig | EIP712Signature | The eip-712 compliant signature to be verified on chain |
Update the contentURI
of a piece of media.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose content uri is being updated |
Update the metadataURI
of a piece of media.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose metadata uri is being updated |
Set an Ask
on a piece of media.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose ask is being set |
ask | Ask | The ask to be set |
Remove the Ask
from a piece of media.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose ask is being removed |
Set a Bid
on a piece of media.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose bid is being set |
bid | Bid | The bid to be set |
Remove the Bid
from a piece of media.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose bid is being removed |
Accept a Bid
on a piece of media.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media whose bid is being accepted |
bid | Bid | The bid to be accepted |
Permit an address to act on behalf of the owner of the media
Name | Type | Description |
---|---|---|
spender | string | The address that is being permitted to spend the media |
media Id | BigNumberish | The ID for the media |
sig | EIP712Signature | The eip-712 compliant signature to be verified on chain |
Burn a piece of media
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media to burn |
As an approved address on a piece of media, revoke your approval.
Name | Type | Description |
---|---|---|
mediaId | BigNumberish | The ID for the media to burn |
Grant approval to the specified address for the specified media on an instance of the Tuli Media Contract
Name | Type | Description |
---|---|---|
to | string | The address being granted approval for the media |
mediaId | BigNumberish | The ID for the media |
Grant approval for all media owner by msg.sender on an instance of the Tuli Media Contract
Name | Type | Description |
---|---|---|
operator | string | The address of the account the approvalForAll is being set |
approved | boolean | Whether or not the operator address is being granted approval |
Transfers the specified media to the specified to address on an instance of the Tuli Media Contract
Name | Type | Description |
---|---|---|
from | string | The from address of the media transfer |
to | string | The to address of the media transfer |
mediaId | BigNumberish | The ID for the media being transferred |
Transfers specified media to the specified address if and only if it adheres to the ERC721-Receiver Interface
Name | Type | Description |
---|---|---|
from | string | The from address of the media transfer |
to | string | The to address of the media transfer |
mediaId | BigNumberish | The ID for the media being transferred |