Skip to content

NEP5 Template for NEO3#187

Merged
lightszero merged 30 commits intoneo-project:masterfrom
belane:nep5-template
Mar 22, 2020
Merged

NEP5 Template for NEO3#187
lightszero merged 30 commits intoneo-project:masterfrom
belane:nep5-template

Conversation

@belane
Copy link
Copy Markdown
Member

@belane belane commented Feb 1, 2020

C Sharp version of the NEP5 template for NEO3 (https://github.com/neo-project/neo/issues/973).

As the nep-5 standard, it includes totalSupply, name, symbol, decimals, balanceOf and transfer methods, and the transfer event.

@shargon
Copy link
Copy Markdown
Member

shargon commented Feb 3, 2020

We need to wait for neo-project/neo#1432

@shargon shargon added the blocked label Feb 3, 2020
@superboyiii
Copy link
Copy Markdown
Member

Good work, I'll test this.

@superboyiii
Copy link
Copy Markdown
Member

I tried this nep5 template on my local environment. It was deployed successfully and then I invoked some static methods such like name or decimals which all returned correct result.
However, when I invoked deploy method, I found tx.Cosigner is null which caused execution failed.
image
image
image
Is there any more we should adjust on compiler? Does it support this kind of style? @lightszero

@shargon
Copy link
Copy Markdown
Member

shargon commented Feb 4, 2020

Cosigners should be [0], not null, @superboyiii please check neo-project/neo-node#539

@doubiliu
Copy link
Copy Markdown
Contributor

doubiliu commented Feb 4, 2020

Format needs to be modified

@erikzhang
Copy link
Copy Markdown
Member

@superboyiii
Copy link
Copy Markdown
Member

superboyiii commented Feb 5, 2020

Cosigners should be [0], not null, @superboyiii please check neo-project/neo-node#539

@shargon I've checked neo-project/neo-node#539, that's OK. But there's another issue that Cosigners is always [0] here which makes usage is always null so that checkwitness isn't able to pass when invoke deploy.
image
image

@shargon
Copy link
Copy Markdown
Member

shargon commented Feb 5, 2020

You received HALT, and should be FAULT, isn't it? @superboyiii

@superboyiii
Copy link
Copy Markdown
Member

You received HALT, and should be FAULT, isn't it? @superboyiii

Yes, that's it. Now I add some logs on every step of Deploy(), you could see that it returns false, but finally receive HALT.
image
image

@shargon
Copy link
Copy Markdown
Member

shargon commented Feb 5, 2020

This CheckWitnessInternal return false, so the execution must be FAULT :S

@superboyiii
Copy link
Copy Markdown
Member

Yes, that's strange.

@belane
Copy link
Copy Markdown
Member Author

belane commented Feb 5, 2020

@belane Did you see https://github.com/neo-project/examples/tree/3.0/nep-5/csharp/NEP5?

@erikzhang yes, what do you prefer? move it, merge or close?

@superboyiii
Copy link
Copy Markdown
Member

superboyiii commented Feb 6, 2020

@erikzhang I think two different templates could exist together since they're in absolutely different repositories. We just need to ensure their methods all meet nep5 standard and work well. This template is using Object-oriented style which is valueable for testing purpose. We can test many features on it.

@doubiliu
Copy link
Copy Markdown
Contributor

doubiliu commented Feb 9, 2020

@erikzhang Both templates are great works. The NEP5 template in the neo/example provides users with a basic Token template, while the Belance's is an extension to meet deeper needs, or we can modify the name of Belance's template to Crowdfunding template.

Copy link
Copy Markdown
Member

@shargon shargon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good template :)

{
return false;
}
Contract.Update(script, manifest);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we send our neo and gas to the next contract or this should be made in the core? 🤔

Copy link
Copy Markdown
Contributor

@Tommo-L Tommo-L Mar 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should move asset to the next contract in the core, as NEO, GAS and data all are protocol layer things. For me, we can treat NEO and GAS as one special data type/properties in contract, so when we update or destory contract, we should handle them.

What do you think? @erikzhang @lightszero

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure which is the best option. 🤔
It would prevent losing assets ​​in hyperspace, but on the other hand, it may exceed the functions of the core.

return false;
}

Contract.Destroy();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we send our neo and gas to the owner or this should be made in the core? 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps there should be a check, if there is neo or gas it returns false.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If one contract hasn't set the verificaiton trigger correctly, it may can't be destoryed never.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These kind of controls are good, we've recommended before, but they are specific to each project.
Each project must implement the measures that fit its business model. As @Tommo-L says if a contract does not include Verification, it is enough to send 1 GAS to prevent them from migrating (or destroy) the contract.

Copy link
Copy Markdown
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good job @belane.

Copy link
Copy Markdown
Member

@lightszero lightszero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code like this is very slow,very very very slow.
and it's expensive,I don't think it is a good idea in template.

//this is a function,compiler do not optimize it.,it will write 20 times
 Owner=>new byte[] { 0xf6, 0x64, 0x43, 0x49, 0x8d, 0x38, 0x78, 0xd3, 0x2b, 0x99, 0x4e, 0x4e, 0x12, 0x83, 0xc6, 0x93, 0x44, 0x21, 0xda, 0xfe };

please use

//compiler can optimze it to a const.
static readonly byte[] owner_var=new byte[] { 0xf6, 0x64, 0x43, 0x49, 0x8d, 0x38, 0x78, 0xd3, 0x2b, 0x99, 0x4e, 0x4e, 0x12, 0x83, 0xc6, 0x93, 0x44, 0x21, 0xda, 0xfe };

@shargon shargon dismissed stale reviews from Tommo-L and superboyiii via b49bc56 March 17, 2020 07:48
@nicolegys
Copy link
Copy Markdown

We need to send notification when destroying the sc, otherwise the plugin RpcNep5Tracker won't know it, the balance of the asset will still exist in its storage.

@erikzhang
Copy link
Copy Markdown
Member

You can check the change set in OnPersist.

@belane
Copy link
Copy Markdown
Member Author

belane commented Mar 19, 2020

We need to send notification when destroying the sc, otherwise the plugin RpcNep5Tracker won't know it, the balance of the asset will still exist in its storage.

In the past we haven't used this kind of notifications, as Erik says you can use OnPersist better since not all projects will include these notifications. But it's something we can consider adding in the future.

@superboyiii
Copy link
Copy Markdown
Member

@lightszero Could you review it again? I think it's OK now.

@lightszero lightszero merged commit 595e898 into neo-project:master Mar 22, 2020
@Tommo-L Tommo-L mentioned this pull request Apr 8, 2020
9 tasks
Jim8y pushed a commit that referenced this pull request Aug 3, 2025
* sc and tests
* dotnet format
* Prepare for new SYSCALL
* Add FeaturesAttribute
* post build SC compilation
* revert GetCurrentTransaction
* Add ContractId
* fix Deploy
* check null balances
* updates from master
* Update crowdsale get balance
Co-Authored-By: Luchuan <luchuan@ngd.neo.org>
* ToBigInteger
* dotnet format
* migrate args
* NeoToken little-endian
Co-Authored-By: GripZhang <xiuboard@foxmail.com>
* GasToken little-endian
Co-Authored-By: GripZhang <xiuboard@foxmail.com>
* totalSupply and ut
* supply factor
* shargon improvements
* li optimizations
* more changes
* add 214
Co-authored-by: Shargon <Shargon@gmail.com>
Co-authored-by: Luchuan <luchuan@ngd.neo.org>
Co-authored-by: GripZhang <xiuboard@foxmail.com>
Co-authored-by: lights li <lightsever@hotmail.com>
Jim8y pushed a commit that referenced this pull request Aug 18, 2025
* sc and tests

* dotnet format

* Prepare for new SYSCALL

* Add FeaturesAttribute

* post build SC compilation

* revert GetCurrentTransaction

* Add ContractId

* fix Deploy

* check null balances

* updates from master

* Update crowdsale get balance

Co-Authored-By: Luchuan <luchuan@ngd.neo.org>

* ToBigInteger

* dotnet format

* migrate args

* NeoToken little-endian

Co-Authored-By: GripZhang <xiuboard@foxmail.com>

* GasToken little-endian

Co-Authored-By: GripZhang <xiuboard@foxmail.com>

* totalSupply and ut

* supply factor

* shargon improvements

* li optimizations

* more changes

* add 214

Co-authored-by: Shargon <Shargon@gmail.com>
Co-authored-by: Luchuan <luchuan@ngd.neo.org>
Co-authored-by: GripZhang <xiuboard@foxmail.com>
Co-authored-by: lights li <lightsever@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants