ARC-0033: Support for global variables #26
tanqiangyes
started this conversation in
ARCs
Replies: 1 comment
-
Thanks for the proposal!
|
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: 33
title: Support for global variables
authors: [email protected]
discussion: Support for global variables
topic: Application
status: Draft
created: 12/6/2022
Abstract
Support for global variables makes leo programs more flexible, just like inside solidity. This will make leo programs more diverse and can be applied to more areas.
In ethereum, we can implement the contract replacement function (by modifying the contract address in the global), and if we implement it in leo, it will greatly increase the activity of leo programs.
For example, if I deploy a board game on top of leo, the current leo's program is not enough to protect the fairness of the game's funds, and a global variable (i.e., the contract deployer) needs to be introduced to collect the funds and distribute the winning and losing funds. This would be the fairest in terms of fairness for all players.
Specification
Here is an example:
global.aleo
As you can see, I set three global variables for "global.aleo",
global_address
,withdraw_address
, andis_set
, which represent the contract deployer, the contract withdrawal account (for game draws, etc.), and whether or not to set This contract does not involve other functions, but only demonstrates how to use global variables.Test Cases
The above contract has no other function than just setting global variables. So we just need to
leo run deploy global_address withdraw_address
to set them and then useleo run get_info
to see if it gives us the same result as we set.Dependencies
This impacts snarkVM, snarkOS, aleo, & leo repositories.
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 solidity example
Beta Was this translation helpful? Give feedback.
All reactions