-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to create accounts with custom code #204
Comments
I would separate creating a new account with custom code and updating code in an account into two separate issues.
This may not be sufficient as besides the code we may need to provide additional data. For example, for basic wallet, we also need to define initial state of the storage (to store the public key for the account). So, we probably need to come up with a more comprehensive approach here to describe not only the MASM code that is needed for the account, but also how the initial state of the storage is to be constructed. |
This is a very good point. Let us use this issue to come up with a solution. We could have a text file
|
I think we may need to have something a bit more sophisticated than this. For example, in the above example it is not clear how the pub key is to be generated (e.g., for which signature scheme) and what the type of the storage slot would be. In general, we need to come up with some kind of account package format. This will also be related to the compiler as the compiler (or at least the Miden SDK part of it) would need to output the full account package which contains not only the code but also the description of the expected storage structure. cc @greenhat and @bitwalker |
Are those two separate questions?
For example, in web3.js the users simply provides a JSON with the contract data in byte code. So we could use a similar method to create accounts with custom code. Then, we could think in our SDK about a method how to compile an account (including its code and storage and keys) into that format. (or is that what you meant with your last comment?) |
I believe we already have this (via importing
This is the main question, I think. And then maybe this is not an issue for the client but for |
Can we already import We can also use the Playground to create custom accounts for builder's testnet @gubloon. |
It is indeed possible to import |
I would probably still keep this issue open for now. It might be good to provide an ability through the client to create custom accounts - even if that's just pass-through functionality for miden base. |
@Dominik1999 just in case this is already possible with |
also, regarding the |
Sorry, I didn't see your response @mFragaBA So the general idea is to be able to write arbitrary smart contracts and deploy them using the Miden client. The problem is the storage layout when creating custom accounts, as described here 0xPolygonMiden/miden-base#550. We have a solution now here 0xPolygonMiden/miden-base#667 |
Yes, closed by #680 |
+++ Updated Issue to summarize the discussion +++
Custom account code allows for general smart contracts
Currently, we only allow users to create accounts with standardized code (basic wallet and faucet). We want users to be able to create accounts with custom code and deploy them on Miden using the Miden client. This is the equivalent of deploying Ethereum smart contracts, and it will widen the space for use cases as users can define their account interfaces.
Importing accounts with custom code into the client
Importing accounts into the Miden client using
... account import <file_name>.mac
is already possible. If the account was created with custom code, importing it already works.The only add-on here would be to show the account code. We could add a CLI command, such as
... account show code
or something similar.This issue in miden-base is related 0xPolygonMiden/miden-base#550
Importing custom code into accounts
I also want to be able to import MASM code into an account. This is related to #220. I want to use
... account new <ACCOUNT TYPE> code <PATH/TO/file_name>.masm
. Then, I want the client to read my custom account code.masm
file. Finally, I want to deploy this account, so I need to execute the first transaction against it and send the data to the Miden Node.Reading in a
.masm
file for account code is not the same as creating a full account from scratch. The user might also want to initialize custom storage or a custom auth scheme. However,AccountStorage
initialization can be done the same way we create accounts in theBasicWallet
. The storage layout would only contain 254 slots and all slot types areStorageSlotType::Value
. Slot0
and256
are reserved for the public key and theLayout
. But this is already done automatically.After initialization, the client should somehow deploy that contract by executing a transaction against it.
The text was updated successfully, but these errors were encountered: