Skip to content

Instantly share code, notes, and snippets.

@tina1998612
Created July 18, 2021 11:17
Show Gist options
  • Save tina1998612/9fbb25dfc82c9cbe42a32f5df417179f to your computer and use it in GitHub Desktop.
Save tina1998612/9fbb25dfc82c9cbe42a32f5df417179f to your computer and use it in GitHub Desktop.
using Neo;
using Neo.SmartContract;
using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Native;
using Neo.SmartContract.Framework.Services;
using System;
namespace Helloworld
{
[ManifestExtra("Author", "Neo")]
[ManifestExtra("Email", "[email protected]")]
[ManifestExtra("Description", "This is a contract example")]
public class Contract1 : SmartContract
{
//TODO: Replace it with your own address.
[InitialValue("NiNmXL8FjEUEs1nfX9uHFBNaenxDHJtmuB", ContractParameterType.Hash160)]
static readonly UInt160 Owner = default;
private static bool IsOwner() => Runtime.CheckWitness(Owner);
// When this contract address is included in the transaction signature,
// this method will be triggered as a VerificationTrigger to verify that the signature is correct.
// For example, this method needs to be called when withdrawing token from the contract.
public static bool Verify() => IsOwner();
// TODO: Replace it with your methods.
public static string MyMethod()
{
return Storage.Get(Storage.CurrentContext, "Hello");
}
public static void _deploy(object data, bool update)
{
if (update) return;
// It will be executed during deploy
Storage.Put(Storage.CurrentContext, "Hello", "World");
}
public static void Update(ByteString nefFile, string manifest)
{
if (!IsOwner()) throw new Exception("No authorization.");
ContractManagement.Update(nefFile, manifest, null);
}
public static void Destroy()
{
if (!IsOwner()) throw new Exception("No authorization.");
ContractManagement.Destroy();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment