Skip to content

Instantly share code, notes, and snippets.

@devhawk
Created May 4, 2021 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devhawk/6d9ba02ae26a7f7618f83087c631fc41 to your computer and use it in GitHub Desktop.
Save devhawk/6d9ba02ae26a7f7618f83087c631fc41 to your computer and use it in GitHub Desktop.
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;
}
}
}
<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