Skip to content

Instantly share code, notes, and snippets.

@mpolci
Created June 26, 2019 15:36
Show Gist options
  • Save mpolci/8d209d4638404cac9c750fcc759221d5 to your computer and use it in GitHub Desktop.
Save mpolci/8d209d4638404cac9c750fcc759221d5 to your computer and use it in GitHub Desktop.
Ganache snaptshots for truffle
function evmSnapshot() {
const res = web3.currentProvider.send({
jsonrpc: '2.0',
method: 'evm_snapshot',
params: [],
id: Date.now()
})
// if (res.error) ... not required in sync call
return res.result
}
function evmRevert(snapId) {
const res = web3.currentProvider.send({
jsonrpc: '2.0',
method: 'evm_revert',
params: [snapId],
id: Date.now()
})
// if (res.error) ... not required in sync call
return res.result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment