Error: Uncaught (in promise) TezosOperationError: (temporary) proto.017-PtNairob.tez.subtraction_underflow
I know this error is caused by a subtraction resulting in a negative number, but i'm just trying a simple code and can't avoid this. My code: import smartpy as sp
FA2 = sp.io.import_script_from_url("https://legacy.smartpy.io/templates/fa2_lib.py")
class Token(FA2.Admin, FA2.MintFungible, FA2.Fa2Fungible):
def __init__(self, admin, **kwargs):
FA2.Fa2Fungible.__init__(self, **kwargs)
FA2.Admin.__init__(self, admin)
class Marketplace(sp.Contract):
def __init__(self, token, metadata, admin):
self.init(
token=token,
metadata=metadata,
admin=admin,
data = sp.big_map(
tkey=sp.TNat,
tvalue=sp.TList(
sp.TRecord(
holder=sp.TAddress,
author=sp.TAddress,
amount=sp.TMutez,
token_id=sp.TNat,
editions=sp.TNat,
collectable=sp.TBool))),
token_id=0)
@sp.entry_point
def send(self, params):
total_price = sp.utils.nat_to_tez(params.total_price)
sp.send(params.account, sp.split_tokens(total_price, 90, 100))
In front-end, i call like this:
...
const op = await contract.methods.send(accountx, 100000).send(100000)
...
Where the 100000 is what i'm trying to send and accountx is account to send.