-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
2,029 additions
and
5 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
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,33 @@ | ||
using Neo.SmartContract.Framework; | ||
using Neo.SmartContract.Framework.Attributes; | ||
using Neo.SmartContract.Framework.Native; | ||
|
||
using System.ComponentModel; | ||
using System.Numerics; | ||
using Neo; | ||
using Neo.SmartContract; | ||
using Neo.SmartContract.Framework.Services; | ||
|
||
namespace ContractCall; | ||
|
||
[DisplayName("SampleContractCall")] | ||
[ManifestExtra("Author", "core-dev")] | ||
[ManifestExtra("Description", "A sample contract to demonstrate how to call a contract")] | ||
[ManifestExtra("Email", "[email protected]")] | ||
[ManifestExtra("Version", "0.0.1")] | ||
[ContractSourceCode("https://github.com/neo-project/neo/examples/ContractCall")] | ||
[ContractPermission("*", "*")] | ||
public class SampleContractCall : SmartContract | ||
{ | ||
[InitialValue("0x13a83e059c2eedd5157b766d3357bc826810905e", ContractParameterType.Hash160)] | ||
private static readonly UInt160 DummyTarget; | ||
|
||
public static void onNEP17Payment(UInt160 from, BigInteger amount, BigInteger data) | ||
{ | ||
UInt160 tokenHash = Runtime.CallingScriptHash; | ||
if (!data.Equals(123)) return; | ||
UInt160 @this = Runtime.ExecutingScriptHash; | ||
BigInteger balanceOf = (BigInteger)Contract.Call(tokenHash, "balanceOf", CallFlags.All, @this); | ||
Contract.Call(DummyTarget, "dummyMethod", CallFlags.All, @this, tokenHash, balanceOf); | ||
} | ||
} |
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,33 @@ | ||
using Neo.SmartContract.Framework; | ||
using Neo.SmartContract.Framework.Attributes; | ||
using Neo.SmartContract.Framework.Native; | ||
using System; | ||
using System.ComponentModel; | ||
using System.Numerics; | ||
|
||
namespace Event; | ||
|
||
[DisplayName("SampleEvent")] | ||
[ManifestExtra("Author", "code-dev")] | ||
[ManifestExtra("Description", "A sample contract that demonstrates how to use Events")] | ||
[ManifestExtra("Email", "[email protected]")] | ||
[ManifestExtra("Version", "0.0.1")] | ||
[ContractSourceCode("https://github.com/neo-project/samples")] | ||
[ContractPermission("*", "*")] | ||
public class SampleEvent : SmartContract | ||
{ | ||
[DisplayName("new_event_name")] | ||
public static event Action<byte[], string, BigInteger> event_name; | ||
|
||
public static event Action<byte[], BigInteger> event2; | ||
|
||
public static bool Main() | ||
{ | ||
byte[] ba = new byte[] { 0x01, 0x02, 0x03 }; | ||
event_name(ba, "oi", 10); // will Runtime.Notify: 'new_event_name', '\x01\x02\x03', 'oi', 10 | ||
|
||
event2(ba, 50); // will Runtime.Notify: 'event2', '\x01\x02\x03', '\x32' | ||
|
||
return false; | ||
} | ||
} |
Oops, something went wrong.