Como poner un address vacio en el state


#1

record state = {
token : Token,
seller : address,
buyer : address,
value : int,
status : statust }

public stateful function init(token : Token, tokens : int ) =
require(tokens > 0, “Value is sub zero”)
{
token = token,
seller = Call.caller,
buyer = // quiero poner el address null para despues setearlo cuando se llama una funcion ,
value = tokens,
status = 0 }


#2

Hola @Cristhen, compartiré tu post con el equipo de desarrollo.


#3

How to put an empty address in the state?
record state = {
token : Token,
seller : address,
buyer : address,
value : int,
status : statust }

public stateful function init(token : Token, tokens : int ) =
require(tokens > 0, “Value is sub zero”)
{
token = token,
seller = Call.caller,
buyer = // I want to put address = null, to set it when a function is called,
value = tokens,
status = 0 }


#4

Address literals are written #<address> so #0 should work in your case.

Another option when you have a variable that does not always have a value is to use an option type.

record state = { buyer : option(address) }
function init() = { buyer = None }
function set_buyer(b : address) = 
  put(state{ buyer = Some(b) })