This repository has been archived by the owner on Nov 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add name service api * update * add english edition of the nns * minor fix
- Loading branch information
1 parent
091bc01
commit d9c2674
Showing
35 changed files
with
2,063 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
docs/en-us/reference/scapi/fw/dotnet/neo/NameService/BalanceOf.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# BalanceOf method (UInt160) | ||
|
||
Gets the registered domains of the specified address. | ||
|
||
Namespace:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) | ||
|
||
Assembly:Neo.SmartContract.Framework | ||
|
||
|
||
## Syntax | ||
|
||
```c# | ||
public static extern BigInteger BalanceOf(UInt160 owner); | ||
``` | ||
|
||
Parameters: | ||
|
||
- owner: the address hash to be queried. | ||
|
||
## Example | ||
|
||
```c# | ||
using Neo; | ||
using Neo.SmartContract.Framework; | ||
using Neo.SmartContract.Framework.Services.Neo; | ||
|
||
public class Demo : SmartContract | ||
{ | ||
public static object BalanceOf(UInt160 Owner) => NameService.BalanceOf(Owner); | ||
} | ||
``` | ||
|
||
After deploying the contract in cli, then you can invoke the contract by typing `invoke 0x1b75e6ea52b9a825ec8d55038296970bf4641696 balanceOf [{"type":"Hash160","value":"0x75b75932a1451cc0c56a95eff7fcc01de45aa5a3"}]`,of which the response is shown as below: | ||
|
||
```json | ||
[{ | ||
"type":"Integer", | ||
"value":"1" | ||
}] | ||
``` | ||
|
||
Response description: | ||
|
||
- Integer type:the number of the domain of the specified address; | ||
|
||
- Others:Failed. | ||
|
||
[Back](../NameService.md) |
91 changes: 91 additions & 0 deletions
91
docs/en-us/reference/scapi/fw/dotnet/neo/NameService/DeleteRecord.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# DeleteRecord method (string, RecordType) | ||
|
||
Deletes the record data. | ||
|
||
Namespace:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) | ||
|
||
Assembly:Neo.SmartContract.Framework | ||
|
||
> [!Note] | ||
> | ||
> Needs to verify the signature of the admin or the owner of the domain name. | ||
## Syntax | ||
|
||
```c# | ||
public static extern void DeleteRecord(string name, RecordType type); | ||
``` | ||
|
||
parameters: | ||
|
||
- name: domain name; | ||
- type: record type. | ||
|
||
## Example | ||
|
||
```c# | ||
using Neo; | ||
using Neo.SmartContract.Framework; | ||
using Neo.SmartContract.Framework.Services.Neo; | ||
using Neo.SmartContract; | ||
|
||
public class Demo : SmartContract | ||
{ | ||
public static void DeleteRecord(string name, byte type) => NameService.DeleteRecord(name, (RecordType)type); | ||
} | ||
``` | ||
|
||
After deploying the contract in cli,you can make a transaction by using [SDK](../../../../../../develop/tool/sdk/transaction.md) to query this method, | ||
|
||
```c# | ||
using Neo; | ||
using Neo.Network.P2P.Payloads; | ||
using Neo.Network.RPC; | ||
using Neo.SmartContract; | ||
using Neo.SmartContract.Native; | ||
using Neo.VM; | ||
using Neo.Wallets; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Utility = Neo.Network.RPC.Utility; | ||
|
||
namespace ConsoleApp1 | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
TestNep17Transfer().GetAwaiter().GetResult(); | ||
Console.Read(); | ||
} | ||
|
||
private static async Task TestNep17Transfer() | ||
{ | ||
RpcClient client = new RpcClient("http://127.0.0.1:10332"); | ||
KeyPair ownerKey = Utility.GetKeyPair("KxrDM5H9TWiLtV48Ckxm15rp6XkxDHNryABGp1u67jRYpw3Y8z9G"); | ||
UInt160 owner = Contract.CreateSignatureContract(ownerKey.PublicKey).ScriptHash; | ||
|
||
Signer[] cosigners = new[] { new Signer { Scopes = WitnessScope.CustomContracts, Account = owner, AllowedContracts = new UInt160[] { NativeContract.NameService.Hash } }}; | ||
|
||
// The hash of the contract we deployed above | ||
UInt160 scriptHash = UInt160.Parse("0x7cc5d85855265ab974885d8852e7569208d3ca05"); | ||
byte[] script = scriptHash.MakeScript("deleteRecord", "test4.com", 1); | ||
|
||
TransactionManager txManager = await new TransactionManagerFactory(client, 5195086) | ||
.MakeTransactionAsync(script, cosigners).ConfigureAwait(false); | ||
Transaction tx = await txManager.AddSignature(ownerKey).SignAsync().ConfigureAwait(false); | ||
|
||
await client.SendRawTransactionAsync(tx).ConfigureAwait(false); | ||
Console.WriteLine($"Transaction {tx.Hash.ToString()} is broadcasted!"); | ||
|
||
WalletAPI neoAPI = new WalletAPI(client); | ||
await neoAPI.WaitTransactionAsync(tx) | ||
.ContinueWith(async (p) => Console.WriteLine($"Transaction vm state is {(await p).VMState}")); | ||
} | ||
} | ||
} | ||
``` | ||
|
||
After running this program, you can get the response `Transaction 0xf66d7382949bf1700da3b86c59e1392b2d9003425d33998f68e76ccd7dfb1bfa is broadcasted!`, which means the success of the transaction. | ||
|
||
[Back](../NameService.md) |
43 changes: 43 additions & 0 deletions
43
docs/en-us/reference/scapi/fw/dotnet/neo/NameService/GetPrice.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# GetPrice method () | ||
|
||
Gets the price of registering or renewing a domain name. | ||
|
||
Namespace:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) | ||
|
||
Assembly:Neo.SmartContract.Framework | ||
|
||
## Syntax | ||
|
||
```c# | ||
public static extern long GetPrice(); | ||
``` | ||
|
||
## Example | ||
|
||
```c# | ||
using Neo; | ||
using Neo.SmartContract.Framework; | ||
using Neo.SmartContract.Framework.Services.Neo; | ||
using Neo.SmartContract; | ||
|
||
public class Demo : SmartContract | ||
{ | ||
public static long GetPrice() { return NameService.GetPrice(); } | ||
} | ||
``` | ||
After deploying the contract in cli, then you can invoke the contract by typing `invoke 0x0830764620067b85f374ef72b2e4f61b7020c620 getPrice`,of which the response is shown as below: | ||
|
||
```json | ||
[{ | ||
"type":"Integer", | ||
"value":"1000000000" | ||
}] | ||
``` | ||
|
||
Response description: | ||
|
||
- Integer type:10 Gas(the decimal is 8)。 | ||
|
||
- Others: failed. | ||
|
||
[Back](../NameService.md) |
48 changes: 48 additions & 0 deletions
48
docs/en-us/reference/scapi/fw/dotnet/neo/NameService/GetRecord.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# GetRecord method (string, RecordType) | ||
|
||
Gets the record data. | ||
|
||
Namespace:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) | ||
|
||
Assembly:Neo.SmartContract.Framework | ||
|
||
## Syntax | ||
|
||
```c# | ||
public static extern string GetRecord(string name, RecordType type); | ||
``` | ||
|
||
parameters: | ||
|
||
- name: domain name; | ||
- RecordType: record type. | ||
|
||
## Example | ||
|
||
```c# | ||
using Neo; | ||
using Neo.SmartContract.Framework; | ||
using Neo.SmartContract.Framework.Services.Neo; | ||
using Neo.SmartContract; | ||
|
||
public class Demo : SmartContract | ||
{ | ||
public static string GetRecord(string name, byte type) { return NameService.GetRecord(name, (RecordType)type); } | ||
} | ||
``` | ||
After deploying the contract in cli, then you can invoke the contract by typing `invoke 0x2d3b9ae14534f5b324dcd36f141272eac403e955 getRecord [{"type":"String","value":"test.com"},{"type":"Integer","value":"1"}]`,of which the response is shown as below: | ||
|
||
```json | ||
[{ | ||
"type":"ByteString", | ||
"value":"MTI3LjAuMC4x" // 127.0.0.1 | ||
}] | ||
``` | ||
|
||
Response description: | ||
|
||
- ByteString type:the Base64-encoded string of the corresponding type data of the domain name; | ||
|
||
- Others:failed. | ||
|
||
[Back](../NameService.md) |
52 changes: 52 additions & 0 deletions
52
docs/en-us/reference/scapi/fw/dotnet/neo/NameService/IsAvailable.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# IsAvailable method (string) | ||
|
||
Checks if the specified second domain name is available. | ||
|
||
Namespace:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) | ||
|
||
Assembly:Neo.SmartContract.Framework | ||
|
||
> [!Note] | ||
> | ||
> The corresponding first-level domain needs to be registered first, otherwise an exception will be thrown. | ||
## Syntax | ||
|
||
```c# | ||
public static extern bool IsAvailable(string name); | ||
``` | ||
|
||
parameters: | ||
|
||
- name: the second domain name to be verified. | ||
|
||
## Example | ||
|
||
```c# | ||
using Neo; | ||
using Neo.SmartContract.Framework; | ||
using Neo.SmartContract.Framework.Services.Neo; | ||
using Neo.SmartContract; | ||
|
||
public class Demo : SmartContract | ||
{ | ||
public static bool IsAvailable(string name) { return NameService.IsAvailable(name); } | ||
} | ||
``` | ||
|
||
After deploying the contract in cli, then you can invoke the contract by typing `invoke 0x614a8f0015607d72cba71659ff83dea33cadb0c1 isAvailable [{"type":"String","value":"test.com"}]`,of which the response is shown as below: | ||
|
||
```json | ||
{ | ||
"type":"Boolean", | ||
"value":"true" | ||
} | ||
``` | ||
|
||
Response description: | ||
|
||
- Boolean type:available if true; | ||
|
||
- Others:failed. | ||
|
||
[Back](../NameService.md) |
52 changes: 52 additions & 0 deletions
52
docs/en-us/reference/scapi/fw/dotnet/neo/NameService/OwnerOf.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# OwnerOf method (string) | ||
|
||
Gets the address of the specified second domain. | ||
|
||
Namespace:[Neo.SmartContract.Framework.Services.Neo](../../neo.md) | ||
|
||
Assembly:Neo.SmartContract.Framework | ||
|
||
> [!Note] | ||
> | ||
> Only the query for the second domain is supported。 | ||
## Syntax | ||
|
||
```c# | ||
public static extern UInt160 OwnerOf(string name); | ||
``` | ||
|
||
Parameters: | ||
|
||
- name: the second domain name to be queried. | ||
|
||
## Example | ||
|
||
```c# | ||
using Neo; | ||
using Neo.SmartContract.Framework; | ||
using Neo.SmartContract.Framework.Services.Neo; | ||
|
||
public class Demo : SmartContract | ||
{ | ||
public static UInt160 OwnerOf(string name) => NameService.OwnerOf(name); | ||
} | ||
|
||
``` | ||
|
||
After deploying the contract in cli, then you can invoke the contract by typing `invoke 0xb35825371fd5ba98a58b4b043aa62e7b0082fd88 ownerOf [{"type":"String","value":"test.com"}]`,of which the response is shown as below: | ||
|
||
```json | ||
[{ | ||
"type":"ByteString", | ||
"value":"o6Va5B3A/PfvlWrFwBxFoTJZt3U=" | ||
}] | ||
``` | ||
|
||
Response description: | ||
|
||
- ByteString type:Base64 encoded string of the account address to which the domain name belongs; | ||
|
||
- Others: failed. | ||
|
||
[Back](../NameService.md) |
Oops, something went wrong.