Hecate2 / neo-fairy-client

Belli dura despicio! Non-official simple client with extended fairy features to test & debug your neo3 smart contract. TODO: Hash160Str('0x'+'00'*19+'02') == '\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'; tx attribute support (NotValidBefore, Conflicts)
MIT License
5 stars 0 forks source link

Can you give a simple example that how to call contract methods with param and sign on the blockchain as a user? #1

Open ssSStking opened 1 year ago

ssSStking commented 1 year ago

Another question, my code: import json from neo_fairy_client.rpc import FairyClient from neo_fairy_client.utils.types import Hash160Str, Signer, WitnessScope

target_url = 'https://n3seed1.ngd.network:10332' wallet_address = 'Naaaaaaaxxxxxxxxxxxxxxcccg' wallet_scripthash = Hash160Str.from_address(wallet_address) wallet_path = 'myNEo.json' wallet_password = '12345678'

client = FairyClient(target_url, wallet_address, wallet_path, wallet_password)

client.openwallet()

Error: neo-fairy-client-3.4.0.1\neo_fairy_client\rpc\fairy_client.py", line 210, in meta_rpc_method raise ValueError(result['error']['message']) ValueError: Access denied

Hecate2 commented 1 year ago

In your case, the method openwallet, as well as all the additional fairy features, are not supported by official RPC servers. Please run your own neo-node in C#, and install your own C# Fairy plugin. Follow http://github.com/Hecate2/how-to-debug-neo if there is any trouble.

Hecate2 commented 1 year ago

https://github.com/Hecate2/neo-fairy-client/commit/60d5bd45ecec0560825b32747e41d8d8bbaa89e8 Additional tutorial to mint billions of NEO and transfer them. All invocations should work on the real testnet and mainnet if the fairy_session string is not specified and transactions are actually valid.

Hecate2 commented 1 year ago

There is a gap that FairyClient is not responsible for signing transactions. After invoking a transaction on the real testnet and mainnet with public RPC server, you cannot relay it if you only have FairyClient. This is because all the signing jobs are run by wallets, while public RPC servers are not responsible for opening your personal wallets. You can run a private https://github.com/Hecate2/neo-fairy-test/ and let it open a wallet and sign transactions automatically for you, or use browser extension wallets (which are not fully automatic for billions of transactions).

Hecate2 commented 4 weeks ago

You can now use client.set_session_fairy_wallet_with_NEP2 . This sends your json wallet NEP-2 private key (and your password) to neo-fairy-test server. You should make sure the server never leaks your private key and password.

from typing import List, Tuple
import json
def read_nep2_file(path: str) -> Tuple[List[Tuple[str, str]], Tuple[int, int, int]]:
    with open(path) as f:
        wallet = json.load(f)
    scrypt_args = wallet["scrypt"]
    (n, r, p) = scrypt_args["n"], scrypt_args["r"], scrypt_args["p"]
    accounts = [(account["address"], account["key"]) for account in wallet["accounts"]]
    return accounts, (n, r, p)
    # client.set_session_fairy_wallet_with_NEP2(account["key"], password, fairy_session)