NEAR Protocol - a sharded, developer-friendly, proof-of-stake public blockchain
Questions tagged [nearprotocol]
636 questions
6
votes
2 answers
Does NEAR need both Serialize and BorshSerialize?
Writing NEAR smart contracts in Rust, my compiler seems to require objects sent through the API to have the Serialize trait, and objects stored in the blockchain to have BorshSerialize and BorshDeserialize. Is that really the case, or am I doing…

Mykle Hansen
- 552
- 3
- 11
6
votes
1 answer
How to get a public key from private key and/or account id in NEAR protocol?
There are various scenarios when you may possess either account id (this is public information) or own the private (secret) key (e.g. extract it from NEAR Wallet local storage), and you want to know the corresponding public key.
What are the options…

Vlad Frolov
- 7,445
- 5
- 33
- 52
6
votes
3 answers
How to encrypt messages with NEAR's account system
NEAR's accounts can have many different key pairs accessing the same account. The keys can also change and rotate. Which means the default way of encrypting messages for specific user with their public key doesn't work.
What is the best pattern to…

ilblackdragon
- 1,834
- 12
- 12
5
votes
1 answer
Does Near Protocol have Callback Signature Verification for Security
The near wallet login callback only provides ?account_id=&all_keys= and the receiving side cannot verify the request is authentically coming from NEAR wallet. Checking the referrer header is unreliable as a hacker can…

Caleb Gates
- 914
- 7
- 20
5
votes
2 answers
How to get private and public keys for the wallet by providing a seed phrase (NEAR Protocol)
I need to be able to get public and private keys for NEAR wallet by providing it's seed-phrase. I've found a specific library/repo in NEAR's GitHub account that looks very promising for my case :) :
https://github.com/near/near-seed-phrase
But,…

Soulwish
- 153
- 1
- 6
5
votes
1 answer
Difference in use cases of near deploy vs near dev-deploy
If I understand it correctly, near dev-deploy creates temporary dev-123-456 account for smart contract while near deploy will use testnet account.
What are different use cases of when to use near deploy to testnet and near dev-deploy?

Ondřej Ševčík
- 1,049
- 3
- 15
- 31
5
votes
1 answer
Near Protocol FunctionCallError(MethodResolveError(MethodNotFound))
I'm new in blockchain, smart contract and near protocol. I'm trying to learn from https://near.academy/ . There's a sample contract on testnet : museum.testnet.
I'm using windows and i installed wsl2.
I can login with
near login command. But after…

Hüseyin Çınar
- 53
- 3
5
votes
2 answers
Contract Predecessor vs Signer vs Current
Can someone help me understand the relationship and distinction amongst these three concepts? It seems like context.predecessor == context.contractName checks are common.

j00yn
- 227
- 1
- 6
5
votes
1 answer
How to change the block timestamp in near_sdk_sim?
I need to change the block_timestamp to test timed voting.
Using VMContext, block_timestamp is changed using:
context.block_timestamp = get_timestamp();
testing_env!(context.clone());
How to do that in near_sdk_sim?
let (root, contract) =…

Amiya Behera
- 2,210
- 19
- 32
5
votes
2 answers
Can I use floating points in near protocol?
Floating point arithmetic is nondeterministic, so blockchain network may not reach agreement on the state of the chain.
I am using the following code in my smart contract to calculate roots:
let mint_value = (juror_stake as f64).powf(0.8) as u128 +…

Amiya Behera
- 2,210
- 19
- 32
5
votes
1 answer
How to get the NEAR public key from the ledger device?
I have a near account with the key that is not on the ledger, and a ledger device with near app.
I want to add the key from the ledger to my near account. For that I need to know the public key associated with (some path on) the ledger. How can I…

Ishamael
- 12,583
- 4
- 34
- 52
5
votes
1 answer
Tracking promise chains in NEAR smart contract protocol
NEAR protocol is sharded and transactions between cross-contract calls in shards are final. In some cases, it would make sense to identify longer transaction chains, especially if the promise chain hits the same contract twice (re-entrancy).
Let's…

Mikko Ohtamaa
- 82,057
- 50
- 264
- 435
5
votes
1 answer
What's the best practice for using env::log in smart-contracts?
In Ethereum Events are clearly defined, each one is a data structure used to signal some action. In Near, env::log are messages.
Example:
In Ethereum we use logs for most of the token state changes
NEP-21 dosn't say anything about logs.
Is there…

Maksym Zavershynskyi
- 856
- 4
- 8
5
votes
2 answers
Which Rust data structures are non deterministic
When writing smart contracts it's important to make sure that all data structures used are deterministic.
Specifically, if HashMap or HashSet are used - is there a possible non determinism coming from Rust standard library?

ilblackdragon
- 1,834
- 12
- 12
5
votes
1 answer
JWT authentication for near protocol in a python backend
In ethereum, JWT authentication takes place with the following process:
https://github.com/Bearle/django-web3-auth/
1) Users sign a message in metamask using accounts private key.
2) account address and the signed message are POSTed to the…

Amiya Behera
- 2,210
- 19
- 32