a small js code to emulate transactions