near-kit effectively, there are only three concepts you need to internalize. If you understand these, you can guess 90% of the API.
Everything hangs off Near
The
Near class is your single entry point. You initialize it once with your configuration (network and credentials), and reuse that instance everywhere.We hate math (Units)
Blockchain development is plagued by unit conversion errors.
near-kit solves this by using Human-Readable Strings.- Amounts: Never count 24 zeros. Use
"1.5 NEAR"or"1 yocto". - Gas: Never calculate gas units. Use
"30 Tgas".
near-kit will throw an error to protect you from mistakes.Transactions are Fluent Chains
NEAR transactions can contain multiple actions (e.g., “Create Account” AND “Transfer Money”).
near-kit models this as a fluent chain.- Start:
.transaction(signer)identifies who is paying. - Chain: Add as many actions as you want (
.transfer,.functionCall). - Send: Call
.send()to sign and broadcast.