Msg/Send

Credits can be sent to another account:

  • when the credit batch exists
  • when the sender has a tradable credit balance greater than or equal to the amount to send
  • when the decimal places in amount to send does not exceed credit type precision
  • the sender credit balance is updated
  • the recipient credit balance is updated
  • the batch supply is updated

The credit batch must exist

the credit batch exists

Given a credit batch with denom "C01-001-20200101-20210101-001"

And alice owns tradable credits with batch denom "C01-001-20200101-20210101-001"

When alice attempts to send credits to bob with batch denom "C01-001-20200101-20210101-001"

Then expect no error.

the credit batch does not exist

When alice attempts to send credits to bob with batch denom "C01-001-20200101-20210101-001"

Then expect the error "could not get batch with denom C01-001-20200101-20210101-001: not found: invalid request".

The sender must have a tradable credit balance greater that or equal to the amount to send

Background

Given a credit batch

And alice owns tradable credit amount "10".

sender has tradable balance greater than or equal to tradable amount to send

When alice attempts to send credits to bob with tradable amount "[amount]"

Then expect no error.

Examples

descriptionamount
greater than5
equal to10

sender has tradable balance less than tradable amount to send

When alice attempts to send credits to bob with tradable amount "15"

Then expect the error "tradable balance: 10, send tradable amount 15: insufficient credit balance".

sender has tradable balance greater than or equal to retired amount to send

When alice attempts to send credits to bob with retired amount "[amount]"

Then expect no error.

Examples

descriptionamount
greater than5
equal to10

sender has retired balance less than retired amount to send

When alice attempts to send credits to bob with retired amount "15"

Then expect the error "tradable balance: 10, send retired amount 15: insufficient credit balance".

The decimal places in amount to send must not exceed credit type precision

Background

Given a credit type with abbreviation "C" and precision "6"

And a credit batch from credit class with credit type "C"

And alice owns tradable credit amount "10".

the decimal places in tradable amount is less than or equal to credit type precision

When alice attempts to send credits to bob with tradable amount "[amount]"

Then expect no error.

Examples

descriptionamount
less than9.12345
equal to9.123456

the decimal places in tradable amount is greater than credit type precision

When alice attempts to send credits to bob with tradable amount "9.1234567"

Then expect the error "9.1234567 exceeds maximum decimal places: 6: invalid request".

the decimal places in retired amount is less than or equal to credit type precision

When alice attempts to send credits to bob with retired amount "[amount]"

Then expect no error.

Examples

descriptionamount
less than9.12345
equal to9.123456

the decimal places in retired amount is greater than credit type precision

When alice attempts to send credits to bob with retired amount "9.1234567"

Then expect the error "9.1234567 exceeds maximum decimal places: 6: invalid request".

The sender balance is updated

Background

Given a credit batch.

the sender tradable balance is updated

Given alice has the batch balance

{
  "retired_amount": "0",
  "tradable_amount": "10",
  "escrowed_amount": "0"
}

When alice attempts to send credits to bob with tradable amount "10"

Then expect alice batch balance

{
  "retired_amount": "0",
  "tradable_amount": "0",
  "escrowed_amount": "0"
}

the sender retired balance is updated

Given alice has the batch balance

{
  "retired_amount": "0",
  "tradable_amount": "10",
  "escrowed_amount": "0"
}

When alice attempts to send credits to bob with retired amount "10"

Then expect alice batch balance

{
  "retired_amount": "0",
  "tradable_amount": "0",
  "escrowed_amount": "0"
}

The recipient balance is updated

Background

Given a credit batch

And alice owns tradable credit amount "10".

the recipient tradable balance is updated

Given bob has the batch balance

{
  "retired_amount": "0",
  "tradable_amount": "0",
  "escrowed_amount": "0"
}

When alice attempts to send credits to bob with tradable amount "10"

Then expect bob batch balance

{
  "retired_amount": "0",
  "tradable_amount": "10",
  "escrowed_amount": "0"
}

the recipient retired balance is updated

Given bob has the batch balance

{
  "retired_amount": "0",
  "tradable_amount": "0",
  "escrowed_amount": "0"
}

When alice attempts to send credits to bob with retired amount "10"

Then expect bob batch balance

{
  "retired_amount": "10",
  "tradable_amount": "0",
  "escrowed_amount": "0"
}

The batch supply is updated

the batch supply is updated

Given a credit batch

And alice owns tradable credit amount "10"

And the batch supply

{
  "retired_amount": "0",
  "tradable_amount": "10",
  "cancelled_amount": "0"
}

When alice attempts to send credits to bob with retired amount "10"

Then expect batch supply

{
  "retired_amount": "10",
  "tradable_amount": "0",
  "cancelled_amount": "0"
}

the batch supply is not updated

Given a credit batch

And alice owns tradable credit amount "10"

And the batch supply

{
  "retired_amount": "0",
  "tradable_amount": "10",
  "cancelled_amount": "0"
}

When alice attempts to send credits to bob with retired amount "10"

Then expect batch supply

{
  "retired_amount": "10",
  "tradable_amount": "0",
  "cancelled_amount": "0"
}

Events are emitted

Background

Given a credit batch with denom "C01-001-20200101-20210101-001"

And alice's address "regen1d466m547y09dgs6xvca7uxs5k2m2pmgspa9kal"

And bobs address "regen10yhlcvh88sux4zmf67udhg5f5z2803z6jm0d25"

And alice owns tradable credit amount "10".

Event EventRetire is emitted

When alice attempts to send credits to bob with retired amount "10" jurisdiction "US-WA" and reason "offsetting electricity consumption"

Then expect event retire with properties

{
  "owner": "regen10yhlcvh88sux4zmf67udhg5f5z2803z6jm0d25",
  "batch_denom": "C01-001-20200101-20210101-001",
  "amount": "10",
  "jurisdiction": "US-WA",
  "reason": "offsetting electricity consumption"
}

Event EventTransfer is emitted

When alice attempts to send credits to bob with retired amount "10" and jurisdiction "US-WA"

Then expect event transfer with properties

{
  "sender": "regen1d466m547y09dgs6xvca7uxs5k2m2pmgspa9kal",
  "recipient": "regen10yhlcvh88sux4zmf67udhg5f5z2803z6jm0d25",
  "batch_denom": "C01-001-20200101-20210101-001",
  "tradable_amount": "0",
  "retired_amount": "10"
}

Event EventTransfer is emitted

When alice attempts to send credits to bob with tradable amount "10"

Then expect event transfer with properties

{
  "sender": "regen1d466m547y09dgs6xvca7uxs5k2m2pmgspa9kal",
  "recipient": "regen10yhlcvh88sux4zmf67udhg5f5z2803z6jm0d25",
  "batch_denom": "C01-001-20200101-20210101-001",
  "tradable_amount": "10",
  "retired_amount": "0"
}