Copying the [implementation in aleph-vm](https://github.com/aleph-im/aleph-vm/pull/180) should be pretty simple. 