Implemented basic token using Move IR

We have built an initial first version of our eTokens on Move IR to experiment and learn more on libra and Move.

(eTokens are the implementation of eToro’s 10 currencies including EURX, JPYX, USDEX, etc and commodities including Gold and Silver that are live as ERC20 complaint tokens on Ethereum, all are also live on eToroX)

We had much excitement and interest to see how to use Move IR and have had a truly joyful ride. We love to share with your our journey on eToroX Labs official github and have you comment, fork, and generally let us know your thoughts and share excitement about Libra and Move!

28 Likes

That is awesome! (And it was fast!)

As i understand of this project, it is equivalent to ERC-20 token standard, correct?

Do you think that the Move IR is already capable of making an ERC-721 type token?
I’m interested in trying that and your project helped a lot. Thank you so much!

4 Likes

Absolutely, I’ll probably start working on something for a general NFT this weekend

4 Likes

Thanks and definitely :slight_smile:

We followed a similar structure to ERC20 and ERC 721 makes sense.

Play a bit with our code and we would love to help :slight_smile:

7 Likes

Great initiative and would love to see the results!

6 Likes

Did you have to change the underlying source code for this to work? Can I deploy this contract on my environment without changing any of the code

1 Like

Nice to see what have bean done by you!

2 Likes

Thanks. The original eToken implementation (as an ERC20 on Ethereum) can be found here https://github.com/etoroxlabs/etoken

We have had to make changes as the original work was developed on solidity for Ethereum and not MOVE. Secondly, as MOVE is not yet released we worked with MOVE IR that was released and had to work on a local environment as it is not possible to deploy on libra testnet. If you follow our instructions on the github you should be able to deploy locally, and feel free to ask question on our github or here if something is not clear so we can better explain it, you can also push contributions yourself so github so everyone else enjoy it or fork it.

Thanks

2 Likes

Thank you very much :slight_smile:

1 Like

Good job. One more question: After running ‘cargo test -p functional_tests eToken’, I got these nice information:
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 224 filtered out

However, how can I really run it on the testnet or locally?

Best,
Dylan

3 Likes

Hi Dylan.

Did you remember to copy the eToken.mvir from the linked repo to the following Libra folder: language/functional_tests/tests/testsuite/module/ or someplace near

Thanks,
Peter Emil Jensen

3 Likes

Thanks for the response. Sure, I put it in the test folders. And the test wen through correctly. In the etoken github, the last step is test. I mean after test, how can I run the move script on the test net or locally.

Best, Dylan

3 Likes

How to get owner’s address in Move contract?

3 Likes

The owner’s address could be your own account’s address. That would make you the owner.
You acquire your address when creating a new Libra account.

1 Like

I know. But if Move contract save some global resource to owner’s account, when other’s call contract, contract how to load the resource from owner’s account? caller should pass the owner’s address?

Others are not meant to load the owner’s resources. It’s only meant to be used by the owner to prove its ownership. The owner account borrow the Owner resource by the function borrow_owner_capability(): &R#Self.Owner and then passes it as a parameter to a privileged function.

The privilged function could be:
grant_minter_capability(receiver: address, owner_capability: &R#Self.Owner)

This ensures that only the owner can access the privileged function, as only the owner can borrow its resource.

Does it make sense?

I know owner_capability, but I want to find a method to save contract’s global state, such as EToken’s total amount.

Okay, I understand what you mean now. This forum post might help you:

And then you will need to hardcode the owner address, and borrow the resource containing the global state. It’s a bit error-prone, but something that will be easier in the future I hope.

3 Likes

I fork and write a hack command to publish module and script for libra.
Improve the etoken move contract, include etoken issue,mint,transfer,buy,sell commands.

Try from

2 Likes

Nice! Thanks for sharing!