Near Protocol: Account Model and Transaction Story

Joshua Kim
5 min readNov 18, 2023

--

DISCLAIMER

This material is based on personal research and study; therefore, it may contain factual errors and cannot be relied upon for critical decision-making. Additionally, the opinions in the material are purely subjective and have no connection to any past or current companies that I have worked at.

CONTENTS

  • Account Model Story
  • Account Model 1) Addresses
  • Account Model 2) Private Keys
  • Account Model 3) A Sample UX Case
  • Transaction Story
  • Transaction 1) Transactions
  • Transaction 2) Actions
  • Transaction 3) Receipts
  • Transaction 4) A Sample Transaction Case
  • Personal Thoughts

Account Model 1) Addresses

There are Two Types of Accounts.

1️⃣ Named Account

  • i.e., alice.near, bob.near, usa.near, texas.usa.near
  • Formatically Same as DNS
  • 🙆🏻‍♂️ usa.neartexas.usa.near can be created.
  • 🙅🏻‍♂️ usa.neartexas.uk.near can NOT be created.

2️⃣ Implicit Account

  • i.e., 98793cd91a3f870fb126f662858[...]
  • Formatically Similar to the Traditional Way to Create Addresses such as Bitcoin and Ethereum (64 letters)

Personal Thoughts

| Named Account

  • Improves the end-user UX of the product because it’s easy to memorize!
  • While ENS is executed at the contract layer, Near’s Named Account is executed at the protocol layer.

| Implicit Account

  • For user groups that want to maintain pseudonymization!
  • For developers accustomed to traditional address systems, especially hardware wallet service companies

Account Model 2) Private Keys

There are Two Types of Private Keys.

https://www.vitalpoint.ai/understanding-near-keys/

1. Full Access Key

| The address can be used to sign transactions of all types.

  • The 8 Types of Transactions (Transaction Actions)
Transfer, # Transfer Tokens
CreateAccount, # Create Accounts
DeleteAccount, # Delete Accounts
DeployContract, # Deploy Contracts
FunctionCall, # Call Functions of Contracts
Stake, # Staking
AddKey, # Add Keys
DeleteKey # Delete Keys

2. Function Call Key

| The address can be used to sign the following restricted transactions.

  • Transactions are restricted to specific Function(s) within a specific contract.

| Sending Native Token, $NEAR, is NOT possible.

  • Gas Fees can be paid, however.
  • Of course, if you set it so that you can’t even pay Gas Fees, only functions related to View methods can be called.

| Purpose of Using Function Call Keys

  • By passing it to the dApp’s client, creating an environment where the dApp can immediately invoke contract calls with limited permissions.
  • Full Access Key
pub enum AccessKeyPermission {
FunctionCall(FunctionCallPermission),
FullAccess,
}
  • Function Call Key
pub struct FunctionCallPermission {
pub receiver_id: AccountId, // a Specific Contract
pub method_names: Vec<String>, // Specific Functions
pub allowance: Option<Balance>, // Max Gas Fee Payment Amount
}

Locked Account

  • Simply remove all keys through the transaction of the DeleteKey action.
  • No one will be able to control the account.
  • In other words, after deploying the smart contract account itself, it can be made fully decentralized, allowing only internal transactions to occur.

Account Model 3) A Sample UX Case

| Typical dApp Transaction Signing Architecture

https://docs.near.org/concepts/web3/near
  • To execute a specific transaction within the dApp, the user must undergo repeated redirection between the wallet and the client.
  • Advantage: Excellent security as the private key is not exposed to the client.
  • Disadvantage: Repeated redirections can be annoying for users.

| dApp Transaction Signing Architecture Using Function Call Key

  • It is possible to address the Disadvantage without significantly compromising the Advantage.
  • 1️⃣ Add Key
https://docs.near.org/concepts/web3/near
  • 2️⃣ Call a Specific Function within a dApp’s Contract
https://docs.near.org/concepts/web3/near

Transaction Story

Overall Execution Flow of the Transactions

https://www.youtube.com/@NEARProtocol

Important Terms

  • Transaction
  • Action
  • Receipt

Transaction Story 1) Transactions

| A Transactions is:

  • a set of actions that need to be performed on the receiving account.
  • 🙅🏻‍♂️ In other words, a transaction is NOT the atomic unit driving state changes in Near Blockchain.

Transaction Story 2) Actions

| An Action is:

  • the unit of work that the virtual machine needs to process through a transaction.
  • There are a total of 8 types recognizable by the Near Protocol. (You have already checked them above!)
Transfer, # Transfer Tokens
CreateAccount, # Create Accounts
DeleteAccount, # Delete Accounts
DeployContract, # Deploy Contracts
FunctionCall, # Call Functions of Contracts
Stake, # Staking
AddKey, # Add Keys
DeleteKey # Delete Keys

Transaction Story 3) Receipts

| A Receipt is:

  • the smallest unit executed by the virtual machine, in other words, the execution object.

Transaction Story 4) A Sample Transaction Case

| A Randomly Chosen Transaction Case

  • 1️⃣ A Transaction Sending 0.02 NEAR.
https://nearblocks.io/txns/6aqjvabatzFkvoBzYmnpEZbAfnLbGo6PsUM6WdpUYxmG#
  • 2️⃣ Receipt Executions (1) TRANSFER Action
https://nearblocks.io/txns/6aqjvabatzFkvoBzYmnpEZbAfnLbGo6PsUM6WdpUYxmG#
  • 2️⃣ Receipt Executions (2) Receiving a Refund for the difference between Gas Limit and Gas Used
https://nearblocks.io/txns/6aqjvabatzFkvoBzYmnpEZbAfnLbGo6PsUM6WdpUYxmG#

Personal Thoughts

1. Protocolized Address System for DNS

| It seems that the computational burden on nodes has been compromised to become a user-friendly blockchain. (Due to the increased size of dtype…)

  • Wouldn’t there be a slowdown and an increase in gas fees then?
  • It seems that this has been addressed by dividing a block into multiple chunks to create the block.
  • Let me study deeper when I have more expertise to check out if there are any potential security drawbacks of this approach. 😁
https://near.org/papers/nightshade

2. Key Generation Structure for dApp End-User UX

| Of course, in the initial Add Key situation, wallet redirection still occurs, so it may not be possible to completely alleviate user confusion.

  • 🗣️Picky Users (say, Joshua): “Earlier, my signature was required, but why are you executing things now without it?” 😠😡
https://docs.near.org/concepts/web3/near

Many Thanks!

👤 Joshua Kim
💼 Data Analyst
🎓 Master in Data Science
🎓 Bachelor in Finance
🎓 Bachelor in Philosophy
🌎 linkedin.com/in/joshuajsk
medium.com/@joshua.web3

REFERENCES

--

--

Joshua Kim
Joshua Kim

Written by Joshua Kim

Analytics Engineer | 🇰🇷🇺🇸🇹🇼

No responses yet