英文:
How to fix ActionNoPermission
问题
我正在尝试使用near-api-py库在allnodes.com上锁定货币,但我遇到了错误:
near_api.account.TransactionError: {'ActionError': {'index': 0, 'kind':
{'ActorNoPermission': {'account_id': 'all nodes.pool v1.near',
'actor_id': 'efe6e8a8f9bc098a672dcfe252a42666dfea38562cf627e5ff8a938c7b.near'}}}}
为什么会出现这个错误?如何修复它并实现质押?谢谢。
我查阅了docs.near.org上的文档,但未找到我需要的解决方案。
英文:
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
答案1
得分: 1
ActorNoPermission
错误表示尝试执行操作的帐户没有权限执行该操作。在这种情况下,操作是质押(staking),尝试执行此操作的帐户是efe6e8a8f9bc098a672dcfe252a42666dfea38562cf627e5ff8a938c7b.near
。
关于NEAR中的质押,重要的是要记住,只有帐户的所有者才能从该帐户中质押NEAR代币。您的错误消息中的actor_id
指示帐户efe6e8a8f9bc098a672dcfe252a42666dfea38562cf627e5ff8a938c7b.near
正在尝试从帐户allnodes.poolv1.near
中质押代币。
allnodes.poolv1.near
是一个质押池合同,通常您需要调用该合同提供的特定方法来存款和质押您的代币。在NEAR中,通常不会直接从您的帐户对验证器进行质押,而是与质押池合同方法互动。
您可能希望将stake
方法调用替换为function_call
方法调用,以与质押池合同互动。您需要调用质押池合同的适当函数,该函数表示存款和质押代币。
以下是伪代码示例:
_account.function_call(
contract_id='allnodes.poolv1.near',
method_name='deposit_and_stake',
args={},
gas=300000000000000,
amount=amount_to_stake,
)
英文:
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,
)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论