Hey community,
I’m Leonardo Lerer from StarkWare’s product team. This is a SNIP that specifies a standard interface between DApps and wallets around account deployment.
title: Deployment interface [Dapps](https://www.starknet.io/ecosystem/dapps) <-> wallets
status: Draft
type: Standard
category: interface
created: 2023-10-23
Simple Summary
An interface for DApps ↔ wallet communication in order to enable a DApp to deploy an account on behalf of a user.
Abstract
In order for a third party (e.g. a DApp) to deploy an existing but non-deployed account in a wallet app, the third party needs to receive the relevant data from the wallet app. This proposal describes a standard interface for the communication between wallets and DApps for the purpose of deploying an account through the Universal Deployer Contract, instead of sending a DEPLOY_ACCOUNT transaction.
Motivation
In order to deploy a new account, a new user usually proceeds as follows:
- Generates data that will be needed to initialize and operate the account contract
- Computes the future address of the account
- Funds this address
- Sends a DEPLOY_ACCOUNT transaction that deploys the account contract at the pre-computed address
Steps 1, 2 and 4 are usually carried out by using a wallet application. Note that, because of account abstraction, the data generated at step 1 is different according to each wallet contract’s logic. With this proposal, we enable deployment of an existing but non-deployed wallet account through the Universal Deployer Contract. This is needed to enable a DApp to take on itself the burden of paying the DEPLOY_ACCOUNT transaction fees on behalf of the user, and therefore making steps 3 and 4 superfluous.
Specification
A method getDeploymentData
associated to each non-deployed wallet account. The method returns the following data:
- class_hash: The class hash of the contract to deploy (of type
felt252
) - salt: The salt used for the computation of the account address (of type
felt252
) - calldata_len: An integer equal to the length of “calldata” below (of type
felt252
) - calldata: An array of felts (of type
Array<felt252>
)
The integer calldata_len MUST be equal to the length of calldata. The OpenAPI specification for the result returned by the method getDeploymentData
is:
{
"result": {
"name": "result",
"description": "The data needed in order to deploy a contract through the universal deployer contract",
"schema": {
"title": "Deployment data",
"type": "object",
"properties": {
"class_hash": {
"title": "Class hash",
"$ref": "#/components/schemas/FELT"
},
"salt" : {
"title": "Salt",
"$ref": "#/components/schemas/FELT"
},
"calldata_len" : {
"title": "Calldata length",
"type": "#/components/schemas/FELT"
},
"calldata": {
"title": "Calldata",
"type": "array",
"items": "#/components/schemas/FELT"
}
}
}
}
"components": {
"schemas":[
{
"FELT": {
"type": "string",
"title": "Field element",
"description": "A field element, represented by at most 63 hex digits",
"pattern": "^0x(0|[a-fA-F1-9]{1}[a-fA-F0-9]{0,62})$"
}
},
]
}
}
These data MUST satisfy the following property. Let us call $class_hash, $salt, $calldata_len, $calldata the output values corresponding to the fields “class_hash”, “salt”, “calldata_len” and “calldata”, respectively. Then, a finalized INVOKE transaction that calls the function deployContract
of the universal deployer contract with parameters
class_hash
: $class_hashsalt
: $saltunique
: 0x0calldata_len
: $calldata_lencalldata
: $calldata
MUST have the same effect as a finalized DEPLOY_ACCOUNT transaction (sent by the pre-computed address) with inputs
class_hash
: $class_hashconstructor_calldata
: $calldatacontract_address_salt
: $salt
i.e., the creation and suitable initialization of an instance of the class $class_hash at the precomputed address.
Copyright
Copyright and related rights waived via MIT.