I'm trying to use the near-api-py library to lock the currency on allnodes.com
def sign_and_send_tx():
_signer = Signer(my_wallet_id, key_pair)
_account = Account(account_id=my_wallet_id, provider=near_provider, signer=_signer)
amount_to_stake = 1 * NEAR
tx = _account.stake(public_key=_signer.public_key, amount=amount_to_stake,
receiver_id=allnodes_validator_id)
return tx
, but I get the error:
near_api.account.TransactionError: {'ActionError': {'index': 0, 'kind':
{'ActorNoPermission': {'account_id': 'all nodes.pool v1.near',
'actor_id': 'efe6e8a8f9bc098a672dcfe252a42666dfea38562cf627e5ff8a938c7b.near'}}}}
why does it occur? how to fix it and implement staking. thanks
I looked through the documentation on docs.near.org . however, I did not find the solution I needed
The ActorNoPermission
error means that the account trying to perform the operation doesn't have permission to do so. In this case, the operation is staking, and the account trying to perform this operation is efe6e8a8f9bc098a672dcfe252a42666dfea38562cf627e5ff8a938c7b.near
.
When it comes to staking in NEAR, it is important to remember that only the owner of an account can stake NEAR tokens from that account. The actor_id
in your error message indicates that the account efe6e8a8f9bc098a672dcfe252a42666dfea38562cf627e5ff8a938c7b.near
is trying to stake tokens from the allnodes.poolv1.near
account.
The allnodes.poolv1.near
is a staking pool contract, you usually need to call the specific methods provided by that contract to deposit and stake your tokens. In NEAR, you typically don't stake to a validator directly from your account, you interact with the staking pool contract methods.
You might want to replace the stake
method call with a function_call
method call to interact with the staking pool contract. You would need to call the appropriate function on the staking pool contract that represents depositing and staking tokens.
Here is a pseudocode example:
_account.function_call(
contract_id='allnodes.poolv1.near',
method_name='deposit_and_stake',
args={},
gas=300000000000000,
amount=amount_to_stake,
)