Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example returns an Integer exception #48

Closed
daxxog opened this issue Mar 6, 2016 · 0 comments
Closed

Example returns an Integer exception #48

daxxog opened this issue Mar 6, 2016 · 0 comments

Comments

@daxxog
Copy link
Contributor

daxxog commented Mar 6, 2016

I ran this code:

    var VM = require('ethereumjs-vm');

    //create a new VM instance
    var vm = new VM();
    var code = '7f4e616d65526567000000000000000000000000000000000000000000000000003055307f4e616d6552656700000000000000000000000000000000000000000000000000557f436f6e666967000000000000000000000000000000000000000000000000000073661005d2720d855f1d9976f88bb10c1a3398c77f5573661005d2720d855f1d9976f88bb10c1a3398c77f7f436f6e6669670000000000000000000000000000000000000000000000000000553360455560df806100c56000396000f3007f726567697374657200000000000000000000000000000000000000000000000060003514156053576020355415603257005b335415603e5760003354555b6020353360006000a233602035556020353355005b60007f756e72656769737465720000000000000000000000000000000000000000000060003514156082575033545b1560995733335460006000a2600033545560003355005b60007f6b696c6c00000000000000000000000000000000000000000000000000000000600035141560cb575060455433145b1560d25733ff5b6000355460005260206000f3';
    //code needs to be a buffer
    code = new Buffer(code, 'hex');

    vm.runCode({
      code: code,
      gasLimit: new Buffer('ffffffff', 'hex') 
    }, function(err, results) {
      console.log(typeof results.exception, results.exception, 'returned: ' + results.return.toString('hex'));
    });

and got this result:

number 1 returned: 7f726567697374657200000000000000000000000000000000000000000000000060003514156053576020355415603257005b335415603e5760003354555b6020353360006000a233602035556020353355005b60007f756e72656769737465720000000000000000000000000000000000000000000060003514156082575033545b1560995733335460006000a2600033545560003355005b60007f6b696c6c00000000000000000000000000000000000000000000000000000000600035141560cb575060455433145b1560d25733ff5b6000355460005260206000f3

why is results.exception === 1? shouldn't it be a boolean type? can someone please explain this example to me and how it works? I'm new to eth and want to use this VM as a simple state machine.

holgerd77 added a commit that referenced this issue Dec 14, 2020
Added Geth read stream example to the README
ryanio pushed a commit that referenced this issue Jan 10, 2022
remove custom util functions, use already existing ones
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants