AssemblyScript compiles a strict variant of TypeScript (basically JavaScript with types) to WebAssembly.
Questions tagged [assemblyscript]
101 questions
8
votes
1 answer
How can I pass an ArrayBuffer from JS to AssemblyScript/Wasm?
I have a pretty straightforward piece of Typescript code that parses a specific data format, the input is a UInt8Array. I've optimized it as far as I can, but I think this rather simple parser should be able to run faster than I can make it run as…

Mad Scientist
- 18,090
- 12
- 83
- 109
7
votes
1 answer
How to print the length of an array in AssemblyScript / Near?
I'm experimenting with simple assembly scripts on near and cannot seem to find a way to print the length of an array. Here's the smallest repro:
let a = new Array();
logging.log(a.length.toString());
Doesn't compile with
ERROR TS2339:…

Ishamael
- 12,583
- 4
- 34
- 52
5
votes
2 answers
Exporting classes from WebAssembly to JavaScript with Assemblyscript?
I'm experimenting with compiling TypeScript to WebAssembly using Assemblyscript and I'm trying to export a class from WebAssembly so that it may be used in the JavaScript. To clarify, I want to be able to construct new instances of the class in a…

Jacob Bohlin
- 165
- 1
- 9
5
votes
1 answer
Working with memory to fetch string yields incorrect result
I am following the solutions from here:
How can I return a JavaScript string from a WebAssembly function
and here:
How to return a string (or similar) from Rust in WebAssembly?
However, when reading from memory I am not getting the desired…

k29
- 641
- 6
- 26
3
votes
1 answer
Cannot find global type CallableFunction
It is a Basic Assembly script project. But I facing this error message in my tsconfig.json file.
{
"extends": "assemblyscript/std/assembly.json",
"include": [
"./**/*.ts"
]
}
It is my package.json
{
"devDependencies": {
…

Ahsan
- 73
- 5
3
votes
0 answers
Cannot find global type 'CallableFunction' error in tsconfig.json file
Basic project.
Everything was working fine when I was using NPM, but to get asbuild, I had to use yarn. But I started to get the error message in my tsconfig.json file.
Cannot find global type 'CallableFunction'
Cannot find global type…

jcloud
- 65
- 5
3
votes
1 answer
How to export classes from AssemblyScript?
I am trying to port my simple collision detection library from JavaScript to WebAssembly for speed. After looking up languages that compile to WASM, AssemblyScript seemed to be perfect as I only needed to add types to my JS file. The whole library…

Paltze
- 57
- 1
- 5
2
votes
1 answer
AssemblyScript: Function working with i32, but not strings
I have an AssemblyScript function that returns any string it is given, as well as the corresponding code to import and run it in NodeJS:
AssemblyScript:
export function parse(x: string): string {
return x;
}
NodeJS:
import { readFileSync } from…

quantasium
- 64
- 7
2
votes
0 answers
how to use interface in assemblyscript
I'm using thegraph which internally uses https://www.assemblyscript.org/
I'm trying to use interface, but it fails: assert failed.
export interface TransactionData {
txHash: Bytes;
timestamp: BigInt;
logIndex: BigInt;
}
Doesn't assemblyscript…

Giorgi Lagidze
- 773
- 4
- 24
2
votes
1 answer
NEAR Locking Funds into smart contract
i'm quite struggling understanding how we can deposit and withdraw funds from smart contract on NEAR blockchain.
I'm currently using near-sdk-as with AssemblyScript. According to documentation I do have…

Retr0
- 21
- 1
2
votes
1 answer
NEARprotocol: Why is AssemblyScript smart contract development only for non financial use cases?
In the NEAR protocol smart contract development documentation for AssemblyScript it says:
Why?

Peter Salomonsen
- 5,525
- 2
- 24
- 38
2
votes
1 answer
How play method works at "NCD.L1.sample--lottery" contract?
Here is the contract repo. https://github.com/Learn-NEAR/NCD.L1.sample--lottery
I don't understand the play method…

Ozan İşgör
- 77
- 6
2
votes
2 answers
How to write data back to storage?
I have a method called changePlaceName and i know it is working but after i call getPlaces to see the changes, i don't see the new place name instead i see the name when i created a new place.
this is changePlaceName
export function…

Çağatay Soyer
- 83
- 4
2
votes
3 answers
AssemblyScript on NEAR: `/bin/sh: asb: command not found` when deploying Guest Book with yarn
When running the GuestBook example on NEAR using yarn deploy the following error is produced:
/bin/sh: asb: command not found
This appears to be happening to people using the Figment Learn NEAR path as well, based on Discord…

Erik Trautman
- 5,883
- 2
- 27
- 35
2
votes
2 answers
What's the correct way to share memory between my AssemblyScript module and my JS?
I'm following this code here, trying to share memory between my AssemblyScript code and my JS:
let aryPtr = instance.exports.allocateF32Array(3);
let ary = new Float32Array(instance.exports.memory.buffer, aryPtr, 3);
ary[0] = 1.0;
ary[1] =…

A_P
- 326
- 1
- 12