After discussion with @yuriko, I found the idea.
Special thank you to @yuriko for having reviewing!
Abstract
Deposit NFT to Predicate and deposit Predicate on Plasma chain.
Challenge that we are facing now:
NFT IDs usually hold 256 byte (uint256), which is more than the current Plasma core’s objectIds is 64 byte field, it include 32 byte start and 32 byte end.
Solution
We can solve this by depositing Predicate that has a map with ETH NFT on Plasma chain. Advantage of this design is that you can simply add this code on the generalized Plasma spec.
Code
NFT mapping predicate pseudo codes: contain mapping NFT id to 32 byte integer
tokens: mapping(uint32, uint256)
# tokenId is within 0-2^32
tokenNonce: uint32
depositedNonce: uint256
def deposit(id: uint256):
tokens[tokenNonce] = id
self.approve(msg.sender, tokenNonce)
self.tokenNonce += 1
def transferFrom(from: address, to: address, amount: uint256):
assert amount == 1
// check approval
// transfer tokens[depositedNonce] to `to` address
self.depositedNonce += 1
// other methods are almost same as ownership predicate
@public
@payable
def onExitGameFinalized(
stateUpdate: StateUpdate
):
assert stateUpdate.start == stateUpdate.end
// tokens[stateUpdate.start] is your NFT id
Common codes to deposit NFT to plasma contract.
NFTMappingPredicate.deposit(nft_id)
PlasmaChain.deposit(1, new StateObject("NFT mapping predicate address", "owner address"))
