A Strong Account in Substrate - Proxy Account

We all know that Substrate's account is a powerful design, and most users are not tech-hardcore, so they will always complain that Polkadot.js is a wallet with a flawed UI/UX, a complaint we also see with MetaMask on Ethereum, but it doesn't affect its monopoly. Of course, there are some great wallets in the DOT ecosystem, such as Talisman (opens in a new tab) and Subwallet (opens in a new tab), that focus on improving the UI/UX of their wallets, supporting features such as multi-chains assets portfolio, stake, and NFT view, but they also drop many of the features supported by Polkadot.js for the sake of a better UI/UX. Now let's introduce a proxy feature that improves the security of accounts in the Substrate chain.

Introduction to Proxy Accounts

The purpose of a proxy account is to reduce the risk of the main account by splitting the functionalities of the account. For example, a full Substrate account has the ability to transfer assets, participate in governance, stake and participate in auctions, etc. We know that the more on-chain activities a user participates in, the more they enter their password, and the more applications they authorize, the more risk they put their account at. That is why we have cold wallets like Ledger, to reduce the on-chain exposure of the account. So if we could split the functionality of our accounts and create a hierarchical system of personal accounts, would that make our accounts even more secure?

pub struct ProxyDefinition<AccountId, ProxyType, BlockNumber> {
    /// The account which may act on behalf of another.
    pub delegate: AccountId,
 
    /// A value defining the subset of calls that it is allowed to make.
    pub proxy_type: ProxyType,
 
    /// The number of blocks that an announcement must be in place for before the corresponding
    /// call may be dispatched. If zero, then no announcement is needed.
    pub delay: BlockNumber,
 
}

We can see that we have designed a structure like this in our account called ProxyDefinition, which contains

Basic functions of a proxy

Since a proxy is an operation that consumes space on the chain, it is inevitable that we need to make a deposit to create it, and we need to pay the appropriate fee to secure the proxy:

Proxy_fee=ProxyDepositBase+ProxyDepositFactornProxy\_fee = ProxyDepositBase + ProxyDepositFactor * n

where ProxyDepositBase is a constant and ProxyDepositFactor is the fee to be paid for the storage consumption caused by each proxy of the account registering on the chain, which is also a state leasing idea.

The basic function of the Proxy Pallet is

It is worth noting that since we will insert the proxies in order to the storage, we can use a binary search for optimization when we search the proxy like this.

let i = proxies.binary_search(&proxy_def).err().ok_or(Error::<T>::Duplicate)?;

Pure Proxy

A brief introduction to the pure proxy.

For the functional implementation of a pure proxy, we only need two main functions:

Time-delayed proxies

Sometimes we choose to finish the call after a certain time in order to guarantee the security of the proxy call, but we need to announce this beforehand, and this is what a delayed proxy is all about.

The implementation is also very simple:

Let's assume a scenario where Alice is the main account and she first adds a proxy account Bob, we give Bob staking access to become Alice's controller and if we need to change the controller to Cathy, we can do so:

1

2

3

4

5

Proxy Calls

Proxy calls are supported in Substrate, i.e. we can initiate a call to another proxy through a proxy account, thus forming a proxy iteration.

Current Problem

Of course, this problem can be solved by secondary development based on the Proxy Pallet, and we are looking forward to good UI/UX wallet integrations such as Talisman and Subwallet for these features, I think the Substrate account is far from reaching its full potential at the moment, so look forward to the rest of the story!

Sign up for our newsletter

Stay up to date with the roadmap progress, announcements and exclusive discounts feel free to sign up with your email.

© By Whisker —@whisker17