near / docs

NEAR Protocol Documentation
https://docs.near.org
Apache License 2.0
150 stars 360 forks source link

[DOC] enhance integrator docs #355

Closed amgando closed 4 years ago

amgando commented 4 years ago

Add the following to integrator section

http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=EXPERIMENTAL_genesis_config

In the response we find "epoch_length":43200 (seconds, ~ 12 hrs)

amgando commented 4 years ago

cc @ilblackdragon @eriktrautman in case we want to share updates to the docs or if i missed something here from my notes

amgando commented 4 years ago

add notes from email thread with @bowenwang1996 's reply

We support both secp256k1 and ed25519 for account keys.

Please check out the spec here on accounts https://nomicon.io/DataStructures/Account.html.

For a transaction, we sign the hash of the transaction. More specifically, what is signed is the sha256 of the transaction object serialized in borsh (https://github.com/near/borsh). For more details on the transaction object, please check out https://docs.near.org/docs/concepts/transaction.

We don't have an implementation in C# or C++. For JS implementation, checkout https://github.com/near/near-api-js/blob/d7f0cb87ec320b723734045a4ee9d17d94574a19/src/transaction.ts#L212. For python implementation, checkout https://github.com/nearprotocol/nearcore/blob/bbd3b9458f46f4b4b0c00f2577b4d8b7b3652920/pytest/lib/transaction.py#L130. Please note that the python implementation is used purely for testing purposes so might not be as polished.

An account can have arbitrarily many keys, as long as it has enough tokens for their storage.

We have a RPC for viewing account state https://docs.near.org/docs/interaction/rpc#view_account. JS implementation https://github.com/near/near-api-js/blob/d7f0cb87ec320b723734045a4ee9d17d94574a19/src/providers/json-rpc-provider.ts#L73. Note that in this rpc you can specify the finality requirement (whether to query the latest state or finalized state). For custody purposes, it is recommended not to rely on latest state but only what is finalized.

This is a very broad question and can take an hour or more to answer in full detail. In short transactions are included in chunks. You can think of a chunk as a shard block. Chunk headers are included in blocks. If you want to learn more, https://docs.near.org/docs/roles/integrator/errors/introduction#the-life-of-a-transaction provides a good start.

For account keys I don't think we plan to change anything. We may support additional curves in the future (I am not aware of any that we are actively considering). For validator keys we are considering switching to bls, but I think that is not important for custody purposes.

We mostly use standard libraries and for signing transactions, there is no crypto that we write on our own.

bowenwang1996 commented 4 years ago

The question about How old can the referenced block hash be before it's invalid? is confusing. It should specify that this is the reference block hash for transactions. Also we currently set it to 86400.

Also note that in the following answer I was talking about crypto related to transactions specifically.

We mostly use standard libraries and for signing transactions, there is no crypto that we write on our own.

We do have crypto that we developed on our own but not for anything related to transactions.

amgando commented 4 years ago

nice, thanks @bowenwang1996

adding @ilblackdragon's clarification from the email thread as well:

To clarify for question of transaction validity, it's 86400 blocks or ~24 hours: https://github.com/nearprotocol/nearcore/blob/master/neard/res/mainnet_genesis.json#L212