Questions tagged [assemblyscript]

AssemblyScript compiles a strict variant of TypeScript (basically JavaScript with types) to WebAssembly.

101 questions
1
vote
2 answers

Assembly script 'create' does not exist on type 'typeof Array'

I am reading the document about the smart contract in Near in Assembly Script. When reading about the Arrays in it. It said "there is two why to initialize an array" var arr = new Array(10); var arr = Array.create(10); when I am…
Rasha
  • 73
  • 7
1
vote
2 answers

Getting error when defining object Type '' is not assignable to type in assembly script (thegraph development)
I'm developing subgraph for indexing blockchain events, but I get error when defining and object ⠋ Compile subgraphERROR TS2322: Type '' is not assignable to type 'i32'. export const FARMS_CONTRACT_NAMES = { BALANCER_LIQUIDITY:…
Mohammad Ranjbar Z
  • 1,487
  • 1
  • 10
  • 20
1
vote
1 answer

ERROR TS6054: File '~lib/@tensorflow/tfjs-node.ts' not found

I'm trying to use AssemblyScript to build a WebAssembly inference engine for a TensorFlow.js model that I have. I started with essentially the quickstart AssemblyScript app (which works great) and then simply added @tensorflow/tfjs to my…
outside2344
  • 2,075
  • 2
  • 29
  • 52
1
vote
2 answers

NEAR smart-contract error: "Contract is not initialized"

I created NEAR smart-contract using Assembly Script and deployed to testnet. When I call any function I receiving error that contract is not initialised (contract was added to workspaces in asconfig.json): Error:…
1
vote
1 answer

The "approve" function in near-example/workshop--exploring-assemblyscript-contracts/assembly/A.sample-projects/04.token-contract/

Do anyone mind explaining the approve and allowance functions in this token smart contract: export function approve(spender: string, tokens: u64): boolean { logging.log("approve: " + spender + " tokens: " + tokens.toString()); …
1
vote
1 answer

Is it possible to import a .wasm file from AssemblyScript?

Can I import .wasm files from my AssemblyScript code? I know I can use the AssemblyScript loader to load .wasm files from TypeScript, but I get errors if I try to build my AssemblyScript example if I follow the instructions found on…
Texagonian
  • 11
  • 3
1
vote
1 answer

Getting “Can not sign transactions for account” error

I am getting Error: Can not sign transactions for account when I call play() on this contract. What causes the error? Here is the code, https://github.com/Learn-NEAR/sample--lottery/blob/main/src/lottery/assembly/index.ts play(): void { …
1
vote
1 answer

memory access out of bounds – but why?

I'm sharing a piece of memory between js and wasm, using 'imported' memory. in my assemblyscript code I'm not even accessing the preallocated memory and still get a RuntimeError: memory access out of bounds. I would like to understand why. js: const…
kindoflike
  • 437
  • 4
  • 16
1
vote
1 answer

How to compile console.log("1") with asc in AssemblyScript?

I want to compile in AssemblyScript (TypeScript) a code that shows a 1, using console.log. My file called example.ts contains the following: console.log("1") I compile it as follows: asc example.ts But I get the following error: ERROR TS2304:…
ArtEze
  • 186
  • 1
  • 5
  • 17
1
vote
1 answer

Manipulating canvas data (typed arrays) by reference using AssemblyScript

I am trying to improve performance of a fairly intensive graphical method by porting it from Typescript to WebAssembly using AssemblyScript. The method manipulates ImageData of a canvas. I am having trouble passing this ImageData (or at least the…
Bram Vanbilsen
  • 5,763
  • 12
  • 51
  • 84
1
vote
1 answer

Does the triple equal sign (===) behave differently in AssemblyScript?

A vendor I use packages their software with AssemblyScript. They provide some infrastructure and I build on top of it. Accidentally, I changed my double equal signs ("==") to triple equal signs ("===") in a function that performs equality checks on…
Paul Razvan Berg
  • 16,949
  • 9
  • 76
  • 114
1
vote
2 answers

Three different ways to instantiate Arrays in AssemblyScript

I'm writing a smart contract and want to use Arrays to manipulate data, but looking at the AssemblyScript docs, I'm not sure the best way to proceed. It seems fine to me to just use: let testData:string[] = [] but when I consulted the…
1
vote
1 answer

TypedArray vs. Array in AssemblyScript

What are some scenarios where you would choose one over the other when programming in AssemblyScript? In my case I am trying to build a K-d tree from a list of tuples of floating point numbers. Because I need to rearrange and sort the incoming list…
chautelly
  • 447
  • 3
  • 14
1
vote
1 answer

Pass arrays from JS by reference for WASM to edit?

What's the best way to pass and return arrays of floats in AssemblyScript? Can I pass an array form JS (by reference) for WASM to edit? export function nBodyForces(data: f64[], result: f64[]): void {} Below is what I have now. Ignore the…
Michael Cole
  • 15,473
  • 7
  • 79
  • 96
1
vote
1 answer

Optimized AssemblyScript still 4K for simple multiply

I'm playing around with AssemblyScript to generate WebAssembly, and I'm not sure why the "optimized" WebAssembly module is so large. I modified the simple add function in the basic tutorial to be a multiplication function that looks like…
Rick Battagline
  • 111
  • 1
  • 3