motoko 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Motoko
2
+
3
+ ### Compile [Motoko](https://smartcontracts.org/) smart contracts in Node.js and the browser.
4
+
5
+ ## Installation:
6
+
7
+ `npm install --save motoko`
8
+
9
+ ## Basic Example:
10
+
11
+ ```js
12
+ import mo from 'motoko';
13
+ // -- OR --
14
+ const mo = require('motoko');
15
+
16
+ // Create a Motoko script in a virtual file system
17
+ mo.addFile('Main.mo', `
18
+ actor {
19
+ public func hello() : async Text {
20
+ "Hello, JavaScript!"
21
+ }
22
+ }
23
+ `);
24
+
25
+ // Generate the corresponding Candid interface
26
+ console.log(mo.candid('Main.mo'))
27
+ ```
28
+
29
+ ## Advanced Usage:
30
+
31
+ ```js
32
+
33
+ // Load dependencies
34
+ await mo.loadPackages({
35
+ base: 'dfinity/motoko-base/master/src',
36
+ });
37
+
38
+ // Generate a Motoko AST
39
+ console.log(mo.parse('actor Main { public func test() : async Nat { 123 } }'));
40
+
41
+ // Generate a Candid AST
42
+ console.log(mo.parseCandid('service : { test : () -> (nat) }'));
43
+ ```
@@ -0,0 +1 @@
1
+ *