Skip to content
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

Write GXChain smart contract with Typescript #1

Open
lanhaoxiang opened this issue Nov 13, 2018 · 4 comments
Open

Write GXChain smart contract with Typescript #1

lanhaoxiang opened this issue Nov 13, 2018 · 4 comments

Comments

@lanhaoxiang
Copy link
Member

Abstract(概要)

GXChain目前集成了WebAssembly的虚拟机,第一个版本实现了C++版本的合约代码编译和运行,AssemblyScript作为TypeScript的一个子集,允许把TypeScript编译成wasm, 这为我们实现typescript编写GXChain智能合约的设想提供了可能。

Motivation(动机)

Typescript是带类型描述的Javascript,其继承了Javascript简洁的语法的同时,带来了强类型的支持,Javascript是目前社区开发者增长最快也是未来最有前景的开发语言之一,如果能够实现Typescript编写智能合约,这将大大降低开发者开发GXChain智能合约的门槛。

Rational(合理性描述)

通过观察appcypher/awesome-wasm-langs这个repo的上展示的支持wasm编译的多种语言编译器进展情况,从技术成熟度角度分析,AssemblyScript目前理论上已经足够完全覆盖GXChain智能合约的基本类型和API要求

此外,目前EOS社区已有类似的想法提出,他们也在各自的想法中论述了自己的观点和合理性描述,可参考eos-typescriptEOSArgentina/eostypescript

因此,从社区需求、技术可信性和产品必要性上来说,通过typescript编写GXChain的智能合约,是合理且可行的。

为了论述技术可信性,本人也实现了一个demo工程,实现了typescript编写Hello world版本的GXChain智能合约lanhaoxiang/gxc-typescript

Specifications(规范)

TODO

@kilmas
Copy link

kilmas commented Dec 29, 2018

应该首先实现JavaScript ^-^

@lanhaoxiang
Copy link
Member Author

@kilmas Javascript是弱类型的语言,无法编译成WASM,但是typescript可以, assembly script可以理解成typescript的一个子集

@kilmas
Copy link

kilmas commented Jan 3, 2019

@lanhaoxiang 可以的,我都用js 写过 eos 的侧链 fibos 合约。

@lanhaoxiang
Copy link
Member Author

@kilmas 研究了一下,fibos应该是用了v8虚拟机,目前也还没开源核心的逻辑。

v8虚拟机我们之前也做了一些调研和技术设计,最后觉得还是wasm虚拟机更具备兼容性和前瞻性。所以既考虑沿用webassembly虚拟机,又要降低开发者门槛,typescript可能是首选

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants