NEAR
NEAR is a user-friendly, scalable layer-1 blockchain platform that uses a sharded proof-of-stake consensus mechanism. It features human-readable account names, supports smart contracts in Rust and AssemblyScript, and offers low transaction fees.Core Concepts
Setting up your wallet
Use the Meteor Wallet to create a Near account. Then go toSettings > Security and Recovery > Export Private Key to copy your private key.
Use the Near Testnet Faucet to airdrop fund your testnet wallet.
Using the SDK
Initialization
Import the SDK and create a new instance:Connecting your wallet
To perform token transfers or other transactions, you need to connect your wallet to the SDK. You also need to provide the accountId to be associated with your private key.getAddress method.
Token transfer
To create a transaction to transfer Ⓝ on near, you can use thepreparePay or prepareTranfer methods:
Uint8Array that can be used in a XM work step.
Signing Messages
Creating accounts
You can call thecreateAccount method to create an account, passing the accountId and the Ⓝ amount to deposit to the created account. You can optionally specify the curve to use when generating the key pair for the new account.
Deleting accounts
You can delete the connected account by calling thedeleteAccount method and passing the NEAR account that will receive the remaining Ⓝ balance from the account being deleted.
Hacking
To create custom transactions for the Near blockchain using the Demos Near SDK, you can access the underlying API to create transactions.| Method | Description | # |
|---|---|---|
instance.actions | Transaction Actions | 1 |
instance.provider | The near class instance provided by near-api-js | 2 |
instance.wallet | Your connected KeyPair | 3 |
instance.signer | The signer for your connected KeyPair | 4 |
instance.signTransaction(s) | Sign transactions | 5 |