the729 / go-libra

Libra go client library with crypto verifications
Apache License 2.0
44 stars 8 forks source link

[Contribute] Supporting submitting Move Script or Module Transactions #4

Closed feliciss closed 4 years ago

feliciss commented 4 years ago

We're considering to develop a new Libra IDE for enabling contract capabilities. However I didn't see there is a SDK to support that functioning as well. Well I think this repo is maintained as so good as sticking with the latest libra testnet, and can be used as frontend javascript library. Therefore, we want to contribute about the move contract interaction code to this repo to enabling that capabilities, not just peer-to-peer-transactions.

the729 commented 4 years ago

I'm glad you found this project.

It's a good proposal to support smart contracts other than simple mint or p2p transactions. The implementation of this go-libra library is to decouple building raw transactions and submitting them.

You may have a look at client/transfer.go. The exported functions SubmitRawTransaction and PollSequenceUntil works for any raw transactions, not limited to p2p transactions. If the user build an arbitrary transaction (which is a types.RawTransaction), he can submit it to the ledger with these functions.

This gives us a clear interface between the client library and the Move compiler. The compiler will generate types.RawTransactions, and the client library will sign and submit it.

feliciss commented 4 years ago

committed as https://github.com/the729/go-libra/pull/6/commits/8463e21ce57520aef55c8ab3ba72d5229ea3bc65.

the729 commented 4 years ago

The recent updates now support submitting raw transactions.

In golang, you can build types.RawTransaction directly, and submit it by calling client.SubmitRawTransaction.

In JS, I have added a new example in example/nodejs/p2p_raw.js and the doc is here: https://www.npmjs.com/package/gopherjs-libra#clientsubmitrawtransactionrawtxn

I'm going to close this issue. Feel free to re-open it if there's any problem.

p.s. the testnet is down at the time I'm writing this.

feliciss commented 4 years ago

thanks!

the729 commented 4 years ago

If you have managed to write/publish/execute a smart contract with this lib, could you please write a detailed blog post or wiki page?

It would be very helpful!

feliciss commented 4 years ago

If you have managed to write/publish/execute a smart contract with this lib, could you please write a detailed blog post or wiki page?

It would be very helpful!

Sure! I’ll write a detailed content for this if we selected this lib for smart contract interaction~