-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathInscription.cs
More file actions
60 lines (55 loc) · 2.14 KB
/
Inscription.cs
File metadata and controls
60 lines (55 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (C) 2015-2026 The Neo Project.
//
// Inscription.cs file belongs to the neo project and is free
// software distributed under the MIT software license, see the
// accompanying file LICENSE in the main directory of the
// repository or http://www.opensource.org/licenses/mit-license.php
// for more details.
//
// Redistribution and use in source and binary forms with or without
// modifications are permitted.
using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Attributes;
using Neo.SmartContract.Framework.Services;
using System;
using System.ComponentModel;
namespace Inscription
{
[DisplayName("SampleInscription")]
[ContractAuthor("core-dev", "dev@neo.org")]
[ContractDescription("A sample inscription contract.")]
[ContractVersion("0.0.1")]
[ContractSourceCode("https://github.com/neo-project/neo-devpack-dotnet/tree/master/examples/")]
[ContractPermission(Permission.Any, Method.Any)]
public class SampleInscription : SmartContract
{
/// <summary>
/// Neo.SmartContract.Examples.Event for logging inscriptions
/// </summary>
[DisplayName("InscriptionAdded")]
public static event Action<UInt160, string> InscriptionAdded;
/// <summary>
/// Method to store an inscription
/// </summary>
/// <param name="address">Address</param>
/// <param name="inscription">Inscription</param>
/// <exception cref="Exception">Failure when is not signed by the address</exception>
public static void AddInscription(UInt160 address, string inscription)
{
if (!Runtime.CheckWitness(address))
throw new Exception("Unauthorized: Caller is not the address owner");
Storage.Put(address, inscription);
InscriptionAdded(address, inscription);
}
/// <summary>
/// Method to read an inscription
/// </summary>
/// <param name="address">Address</param>
/// <returns>Inscription readed</returns>
[Safe]
public static string GetInscription(UInt160 address)
{
return Storage.Get(address);
}
}
}