git ssb

0+

wanderer🌟 / js-primea-hypervisor



Tree: 3b07461593e97b8ecb99d055a38948670485d41e

Files: 3b07461593e97b8ecb99d055a38948670485d41e / test.js

2012 bytesRaw
1const Kernel = require('./index.js')
2const Environment = require('./environment.js')
3
4const environment = new Environment()
5const kernel = new Kernel(environment)
6
7const Address = require('./address.js')
8const U256 = require('./u256.js')
9
10const fs = require('fs')
11
12environment.addAccount(new Address('0x1234567890134561111123412341234123412341'), { balance: new U256('100000000000000000') })
13// environment.addAccount(new Address('0x4123412341234123411234567890134561111123'), { code: Uint8Array.from(fs.readFileSync('identity.wasm')) })
14
15environment.addAccount(new Address('0xbe862ad9abfe6f22bcb087716c7d89a26051f74c'), { balance: new U256('100000000000000000') })
16var tx = new Buffer('f8e380648203e88080b8977f4e616d65526567000000000000000000000000000000000000000000000000003057307f4e616d6552656700000000000000000000000000000000000000000000000000573360455760415160566000396000f20036602259604556330e0f600f5933ff33560f601e5960003356576000335700604158600035560f602b590033560f603659600033565733600035576000353357001ca0b8b9fedc076110cd002224a942e9d7099e4a626ebf66cd9301fc18e2c1181806a04e270be511d42189baf14599eb8d6eb5037ab105032dd3e0fa05b43dad4cb4c2', 'hex')
17console.log(kernel.runTx(tx, environment))
18
19// deploy contract
20let ret = kernel.runTx({
21 nonce: new U256(3),
22 from: new Address('0x1234567890134561111123412341234123412341'),
23 to: new Address('0x0000000000000000000000000000000000000000'),
24 value: new U256('100'),
25 gasLimit: new U256('1000000000'),
26 gasPrice: new U256(1),
27 data: Uint8Array.from(fs.readFileSync('identity.wasm'))
28}, environment)
29console.log('Account created: ' + ret.accountCreated)
30
31ret = kernel.runTx({
32 nonce: new U256(4),
33 from: new Address('0x1234567890134561111123412341234123412341'),
34 to: ret.accountCreated, // new Address('0x4123412341234123411234567890134561111123'),
35 value: new U256('100'),
36 gasLimit: new U256('1000000000'),
37 gasPrice: new U256(1),
38 data: Uint8Array.from(new Buffer('spartaaaa'))
39}, environment)
40
41console.log('Return value: ' + ret.returnValue)
42

Built with git-ssb-web