如何修复ActionNoPermission

huangapple go评论68阅读模式
英文:

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,
)

huangapple
  • 本文由 发表于 2023年6月26日 16:09:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76554740.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定