Authentication/Key Management
Our interfaces require two keys to access, Orderly Key Pair (ed25519
) and Trading Key Pair (secp256k1
). Orderly Access Key Pair is generated by the wallet and more information can be found here and instructions on how to create the keys can be found here. Trading keys can either be retrieved from a GUI or generated on your own.
It is recommended to use function call keys rather than full access keys for safety
Storage Deposit
storage_deposit
Parameters:
args: {
account_id: "NEAR account ID" //optional
registration_only: "bool" //optional
}
Registers an account in the smart contract/Deposit storage fee*
*It cannot be used without any deposit attached
This API creates a NEAR account_id in the Orderly contract or is used to top up storage deposit and is a payable method, thus requires a specified amount of NEAR to be attached when first registering an account. The required amount can be retrieved using storage_balance_bounds
.
If registration_only
=true
only the minimum required NEAR amount to register an account is accepted which can be retrieved using storage_balance_bounds
. This cannot be true if the account already exists.
If the account already exists or the value of registration_only
=false,
it can also be omitted.
Any data stored in the contract, such as setting Access/Trading keys, token balance, etc., requires storage staking as per NEAR architecture
Set Orderly Key
user_announce_key
Parameters:
// Parameters are optional and are only for cross-contract calls
// The key that signs this transaction will be registered if public_key is null
args: {
//optional and is only required for cross-contract calls
public_key: "ed25519: Public Orderly Access key",
}
Setting Access Keys requires a storage deposit
Binds Orderly Access Keys to the smart contract
Set Trading Key
user_request_set_trading_key
Parameters:
args: {
//optional and is only required for cross-contract calls
//if empty, the key used to sign this transaction will be used
public_key: "ed25519: Public Orderly Access key"
key: normalizeTradingKey,
}
Creates and binds a user’s trading key to a user’s Orderly Key
Trading keys are generated using elliptic-curve cryptography and normalized using the following format:
Step 1: Hex the public key
Step 2: Remove ‘04’ if present
Step 3: Hash it using keccak256
Step 4: Covert the result into a hex string
Step 5: Pass base64 of the resulting string
Check if Orderly Key Set
is_orderly_key_announced
Parameters:
args: {
user: accountId,
//optional and is only required for cross-contract calls
orderly_key: orderlyKeyPair.getPublicKey().toString(),
}
Check if Trading Key Set
is_trading_key_set
Parameters:
args: {
user: accountId,
//optional and is only required for cross-contract calls
orderly_key: orderlyKeyPair.getPublicKey().toString(),
}
Remove Access Key
user_request_key_removal
Parameters:
args: {
//optional and is only required for cross-contract calls
public_key: "ed25519: Public Orderly Access key",
}