NEAR
The method names below are based on the Bridge Wallets Standard for NEAR.
near_getAccounts
Retrieve all accounts visible to the session. publicKey
references the underlying FullAccess
key linked to each account.
Parameters
none
Returns
1.Array
- Array of accounts:
1.1. Object
1.1.1. accountId
: String
- The account name to which the publicKey corresponds as plain text
1.1.2. publicKey
: String
- The public counterpart of the key used to sign, expressed as a string with format <key-type>:<base58-key-bytes>
Example
// Request
{
"id": 1,
"jsonrpc": "2.0",
"method": "near_getAccounts",
"params": {}
}
// Result
{
"id": 1,
"jsonrpc": "2.0",
"result": [{
"accountId": "alice.near",
"publicKey": "ed25519:DmnRVNb89cLKZY1cH1Zcr3rxMVD9r1cVfnDac7RFwM94"
}]
}
near_signIn
For dApps that often sign gas-only transactions, FunctionCall
access keys can be created for one or more accounts to greatly improve the UX. While this could be achieved with signTransactions
, it suggests a direct intention that a user wishes to sign in to a dApp's smart contract.
Parameters
Object
- Sign In parameters: 1.1.permission
:Object
- Function call key permission parameters 1.1.1.receiverId
:String
- smart contract for which the function call access key will be created 1.1.2.methodNames
:Array<String>
- list of methods that can be called on the smart contract 1.2.accounts
:Array
- list of accounts for which a FunctionCall access key will be added: 1.2.1.Object
- Account 1.2.1.1.accountId
:String
- The account name to which the publicKey corresponds as plain text 1.2.1.2.publicKey
:String
- The public counterpart of the key used to sign, expressed as a string with format<key-type>:<base58-key-bytes>
Returns
void
Example
// Request
{
"id": 1,
"jsonrpc": "2.0",
"method": "near_signIn",
"params": {
"permission": {
"receiverId": "guest-book.testnet",
"methodNames": []
},
"accounts": [{
"accountId": "alice.near",
"publicKey": "ed25519:DmnRVNb89cLKZY1cH1Zcr3rxMVD9r1cVfnDac7RFwM94"
}]
}
}
near_signOut
Delete one or more FunctionCall
access keys created with signIn
. While this could be achieved with signTransactions
, it suggests a direct intention that a user wishes to sign out from a dApp's smart contract.
Parameters
1.Array
- Array of accounts:
1.1. Object
1.1.1. accountId
: String
- The account name to which the publicKey corresponds as plain text
1.1.2. publicKey
: String
- The public counterpart of the key used to sign, expressed as a string with format <key-type>:<base58-key-bytes>
Returns
void
Example
// Request
{
"id": 1,
"jsonrpc": "2.0",
"method": "near_signOut",
"params": {
"accounts": [{
"accountId": "alice.near",
"publicKey": "ed25519:DmnRVNb89cLKZY1cH1Zcr3rxMVD9r1cVfnDac7RFwM94"
}]
}
}
near_signTransaction
Sign a transaction. It makes use of near-api-js to enable interoperability with dApps that will already use it for constructing transactions and communicating with RPC endpoints.
Transaction passed to signTransaction
must be encoded.
Parameters
Object
- Signing parameters: 1.1.transaction
:Uint8Array
- Encoded Transaction via transactions.Transaction.encode()
Returns
The result of signTransaction
and is encoded SignedTransaction model.
Uint8Array
- Encoded SignedTransaction via transactions.SignedTransaction.encode()