Grants & Transfers

Granting an Asset

Assets can be granted as easily as they can be created. Simply call tephra.grant with a valid address and any user ID. Once an address is granted, a user can validate their ownership of the asset on your platform, on the Asset's public page on Tephra Validate, and in our preserved changes.

await tephra.grant(assetAddress, toUserId)

// For example:
const asset = await tephra.create()
const user = "f39cb85bec99"
await tephra.grant(asset, user)

An asset can only be granted once. When you request a grant, we ensure that an asset exists at the requested address, that it's under your control, and that it hasn't been granted yet.

These user IDs will be preserved publicly in a changeset chunk. That's the value of Tephra. Make sure to keep PII out of these IDs.

Transferring an Asset

Transfers are very similar to grants, but they include a "From User" and a "To User". By requiring the "From User", we ensure that the user initiating the transfer is the current owner. This greatly simplifies implementation because you don't have to make these assurances on your end.

await tephra.transfer(assetAddress, fromUserId, toUserId)

// For example:
const asset = await tephra.create()
const user1 = "f39cb85bec99"
const user2 = "236bb7c8675f"

await tephra.grant(asset, user1)
// now user1 owns the asset

await tephra.transfer(asset, user1, user2)
// now user2 owns the asset

An asset can only be transferred if it exists, has been granted, and hasn't been ejected from Tephra.

Last updated

Was this helpful?