Created
May 4, 2021 18:38
-
-
Save devhawk/6d9ba02ae26a7f7618f83087c631fc41 to your computer and use it in GitHub Desktop.
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
using Neo; | |
using Neo.SmartContract.Framework; | |
using Neo.SmartContract.Framework.Services; | |
namespace DevHawk | |
{ | |
public class TestContract : SmartContract | |
{ | |
StorageMap domains = new StorageMap(Storage.CurrentContext, nameof(domains)); | |
UInt160 GetDomainOwner(string domain) | |
{ | |
var value = domains.Get(domain); | |
return (value == null) ? UInt160.Zero : (UInt160)value; | |
} | |
public bool Register(string domain, UInt160 owner) | |
{ | |
var currentOwner = GetDomainOwner(domain); | |
if (!currentOwner.IsZero) | |
{ | |
Runtime.Log("Domain already registered"); | |
return false; | |
} | |
if (!Runtime.CheckWitness(owner)) | |
{ | |
Runtime.Log("CheckWitness Failed"); | |
return false; | |
} | |
domains.Put(domain, owner); | |
return true; | |
} | |
} | |
} |
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
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<TargetFramework>net5.0</TargetFramework> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="Neo.SmartContract.Framework" Version="3.0.0-rc2" /> | |
</ItemGroup> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment