ARC-0030: Adding self.parent opcode #11
evanmarshall
started this conversation in
ARCs
Replies: 2 comments
-
Thanks for designing the proposal and starting the conversation! A few comments/questions:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
In my opinion, self.parent == self.caller, and self.signer is different |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
arc: 0030
title: Adding self.parent opcode
authors: [email protected] [email protected]
discussion: ARC-0030: Adding self.parent opcode
topic: Application
status: Draft
created: 9/2/2022
Abstract
Let's get NFTs & Tokens/DeFI working on Aleo. Currently, you can create an ERC-20/ERC-721-like program on Aleo but it is severly limited.
The biggest limitation is that a program cannot own an NFT. This prevents these Aleo tokens from being used in: escrow, auctions, pools, etc.
In order to enable this functionality, we need an opcode in the Aleo instruction set like:
self.parent
. This opcode would be similar toself.caller
except it would result in the address of the program who called another program.By creating this opcode, we could design token/nft programs to enable ownership through a public mapping, enabling Aleo users to transfer assets to a program. A program could then hold them in escrow and only release them as dictated through the smart contract.
In Solidity, there's a concept of
tx.origin
->self.caller
andmsg.sender
. Currently, there's nomsg.sender
equivalent in Aleo.Specification
self.parent
should default to the address of the calling program if there is one. If there isn't a calling program, it should result in the same address asself.caller
.In our AMM example, we define toy token and amm programs to demonstrate how
self.parent
would be used to enable a program to own assets. Intoken.aleo
, a user can transfer assets to a program (amm.aleo
) by callingtransfer
and assets can be transferred out of the pool by callingtransfer_program
. Effectively,self.parent
givesamm.aleo
exclusive control to decide how its balance intoken.aleo
is decremented. In our case, we show how a toy AMM could enable pool deposits/lp share issuance, lp share redemption, and swaps.Test Cases
aleo run get_foo
->address(foo.aleo)
aleo run get_bar
->address(self.caller)
Dependencies
This will impact snarkVM and everything that has snarkVM as a dependency.
Backwards Compatibility
As this is a new feature, no programs should be impacted by adding a new opcode.
Security & Compliance
There should be no regulatory concerns.
References
Explanation of tx.origin vs msg.sender in etherem
How self.caller was implemented
External calls in SnarkVM
Beta Was this translation helpful? Give feedback.
All reactions