-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Charity address generator #53
Comments
Is this a proposal? It's not a dapp? |
Hi, Erik.
|
I think this could be a template, not a standard. |
Yes, a template. You are right. We just worry, a little bit, if the Wallet Clients would know how to handle such contracts. |
Wallets can handle it with its ABI. See https://github.com/neo-project/proposals/blob/master/nep-3.mediawiki |
Precise as a 🗡️ The ABI template is useful and well-described, the C# ABI info is used at https://neocompiler.io/#/ecolab A template + its standard generated ABI should be enough.
It needs to be split in some additional functions, which would help comprehension. |
@vncoelho I think we can do that as a regular wallet as @erikzhang mentioned (using some OpCode magic tricks): // NEP Charity Donations - Remote GAS Claim
using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Services.Neo;
using Neo.SmartContract.Framework.Services.System;
using System;
using Neo.VM;
namespace Neo.SmartContract
{
public class NepCharityDonation : Framework.SmartContract
{
[OpCode(OpCode.CHECKSIG)]
protected extern static bool VerifySignature2(byte[] pubkey);
[OpCode(OpCode.DUP)]
protected extern static void Duplicate();
[OpCode(OpCode.DROP)]
protected extern static void Drop();
//private static readonly byte[] OwnerSH = "AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y".ToScriptHash();
//private static readonly byte[] CharitySH = "APLJBPhtRg2XLhtpxEHd6aRNL7YSLGH2ZL".ToScriptHash();
public static readonly byte[] Owner = "031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a".HexToBytes();
public static readonly byte[] Charity = "036245f426b4522e8a2901be6ccc1f71e37dc376726cc6665d80c5997e240568fb".HexToBytes();
private static readonly byte[] NeoAssetId = { 155, 124, 255, 218, 166, 116, 190, 174, 15, 147, 14, 190, 96, 133, 175, 144, 147, 229, 254, 86, 179, 74, 92, 34, 12, 205, 207, 110, 252, 51, 111, 197 };
private static readonly byte[] GasAssetId = { 231, 45, 40, 105, 121, 238, 108, 177, 183, 230, 93, 253, 223, 178, 227, 132, 16, 11, 141, 20, 142, 119, 88, 222, 66, 228, 22, 139, 113, 121, 44, 96 };
// Verification Contract (no need for deploy)
public static bool Main()
{
if (Runtime.Trigger != TriggerType.Verification) // see NEP-7 final situation
throw new Exception();
Duplicate(); // duplicate signature on main stack
// Owner can manage all funds
//if(Runtime.CheckWitness(Owner))
if(VerifySignature2(Owner)) {
Drop(); // eliminate second signature from main stack
return true;
}
// Verify if it's the Charity address
//if(Runtime.CheckWitness(Charity))
if(VerifySignature2(Charity)) {
// Get outputs
Transaction tx = (Transaction)ExecutionEngine.ScriptContainer;
TransactionOutput[] outputs = tx.GetOutputs();
// Verify if this is a self transfer of NEO
if((outputs.Length == 1) && (outputs[0].AssetId == NeoAssetId) && (outputs[0].ScriptHash == ExecutionEngine.ExecutingScriptHash))
return true;
// Verifing if all outputs are GAS type
foreach (TransactionOutput output in outputs)
if (output.AssetId != GasAssetId)
return false;
return true;
}
return false;
}
}
} |
@vncoelho @lerider Finally, this example is working under SMACCO logic: https://github.com/neoresearch/smacco (https://neoresearch.io/smacco-demo) {
"standard": "smacco-1.0",
"input_type" : "single",
"pubkey_list" : ["031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a", "036245f426b4522e8a2901be6ccc1f71e37dc376726cc6665d80c5997e240568fb"],
"rules" : [
{
"rule_type": "ALLOW_IF",
"condition" : {
"condition_type" : "CHECKSIG",
"pubkey" : "0"
},
},
{
"rule_type": "ALLOW_IF",
"condition" : {
"condition_type" : "AND",
"conditions" : [
{
"condition_type" : "CHECKSIG",
"pubkey" : "1"
},
{
"condition_type" : "OR",
"conditions" : [
{
"condition_type" : "AND",
"conditions" : [
{
"condition_type" : "SELF_TRANSFER"
},
{
"condition_type" : "ONLY_NEO"
}
]
},
{
"condition_type" : "ONLY_GAS"
}
]
},
]
},
},
],
"default_rule" : "DENY_ALL"
} It can also be compiled and generate Address online at: https://neoresearch.io/smacco-demo |
Incredible, brother. You did this like a Leopard. Impressive. Lets include this in our course for the 4th quarter of 2018 |
It generates C# and flowchart automatically now ;) Classic timelock (https://neoresearch.io/smacco): |
This issue was reopened due to the great effort and work done for reaching this impressive Smart Account Composer. |
Perhaps we can propose a NEP to replace smacco specification Vitor... then community may contribute with features that could be useful on most smart accounts. We already have timelock, multisig, asset limits, but we can think of many more. It would be nice to replace |
Perfect, Igor. |
Time to close this...aheuiaheuaea I still believe we should evolve the language and the tool further in a near future. |
If we make verification turing incomplete, this never could be done |
No @shargon, it can be done, this was a template for UTXOs complex operation. |
Hi, everyone.
@lerider commented about his idea to design a donation address, which would be able to send
GAS
but do not sendNeo
assets (claim would be a source of tokens for the charity and is, consequently, needed. Thus, send NEO to itself should be allowed).The first idea (@igormcoelho) was to design something like this:
However, we realized that we should use
VerifySignature
instead ofRuntime.CheckWitness
, which requires us to send signature as a parameter, right?What do you recommend, @erikzhang ?
A1)
VerifySignature
would imply in an adjustment on the wallet for sending from this type of address.A2) We could design other type of contract that blocks sending to other addresses.
But, perhaps, a password should be used for avoiding malicious transfer back to the OWNER (which would bother the charity address).
The text was updated successfully, but these errors were encountered: