Skip to content

Instantly share code, notes, and snippets.

@toonsevrin
Created May 23, 2018 11:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toonsevrin/26498311ee024afbca0d890badf5f4f8 to your computer and use it in GitHub Desktop.
Save toonsevrin/26498311ee024afbca0d890badf5f4f8 to your computer and use it in GitHub Desktop.
Getting started:
1. Follow this tutorial: https://github.com/AssemblyScript/assemblyscript/wiki/Hello-World to get your environment setup
2. Change the scripts section of your package.json to the one provided in this gist (the only real difference is the --use abort= tag).
3. Use the module.ts provided in this gist for your module source (in the assembly directory).
4. "npm run build" will create your binaries (perhaps you have to mkdir build first though).
5. Uploading to eos requires an abi file, using one of another contract is completely fine though, as our contract does not use any action data.
=> After uploading the abi together with build/untouched.wasm you can push an action to your contract and Hello, World! will be printed.
"scripts": {
"build": "asc assembly/module.ts -t build/untouched.wat -b build/untouched.wasm --sourceMap --measure --noAssert --use abort=",
}
import "allocator/arena";
/**
* Eos environment function to print a utf-8 encoded string, identified by its pointer, to the console.
* AssemblyScript strings are encoded in utf-16le so we first convert these to latin.
*
*/
declare function prints(pointer: usize): void;
/**
* Entrypoint for the eos contract
*
*/
export function apply(receiver: u64, code: u64, action: u64): void {
prints("Hello, World!".toUTF8());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment