> For the complete documentation index, see [llms.txt](https://docs.gooddollar.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gooddollar.org/for-developers/core-contracts/onetimepayments.md).

# OneTimePayments

G$s are held in an escrow and the recipient can retrieve the funds if he has the key. While the money is in escrow the sender can choose to cancel the payment and retrieve the funds. Based on [Celo's](https://github.com/celo) payments contract.

### Events

#### PaymentDeposit

Emitted when payment was performed. Occurs only during the token contract call.

<table><thead><tr><th width="389.63805195347794">Parameter name</th><th>Annotation</th></tr></thead><tbody><tr><td>from</td><td>The address of the tokens sender.</td></tr><tr><td>paymentId</td><td>The address representing an ID of the payment.</td></tr><tr><td>amount</td><td>Amount of the payment.</td></tr></tbody></table>

```
event PaymentDeposit(address indexed from, address paymentId, uint256 amount);
```

To deposit a payment to a one time payment address call perform the further:

```
GoodDollar.transferAndCall(value, data);
```

The above will trigger OneTimePayments onTokenTransfer callback, which will trigger the PaymentDeposit.

#### PaymentCancel

Emitted when payment was cancelled.

<table><thead><tr><th width="223.06025121092682">Parameter name</th><th>Annotation</th></tr></thead><tbody><tr><td>from</td><td>The address of the tokens sender.</td></tr><tr><td>paymentId</td><td>The address representing an ID of the payment.</td></tr><tr><td>amount</td><td>Amount of the payment.</td></tr></tbody></table>

```
event PaymentCancel(address indexed from, address paymentId, uint256 amount);
```

#### PaymentWithdraw

Emitted when payment was withdrawn.

<table><thead><tr><th width="223.06025121092682">Parameter name</th><th>Annotation</th></tr></thead><tbody><tr><td>from</td><td>The address of the tokens sender.</td></tr><tr><td>to</td><td>The address of the tokens receiver.</td></tr><tr><td>paymentId</td><td>The address representing an ID of the payment.</td></tr><tr><td>amount</td><td>Amount of the payment.</td></tr></tbody></table>

```
event PaymentWithdraw(
    address indexed from,
    address indexed to,
    address indexed paymentId,
    uint256 amount
);
```

### withdraw

Withdrawal function.

<table><thead><tr><th width="301.8711599216471">Parameter name</th><th>Annotation</th></tr></thead><tbody><tr><td>paymentId</td><td>The address of the public key that the rightful receiver of the payment knows the private key to.</td></tr><tr><td>signature</td><td>The signature of a the message containing the <code>msg.sender</code> address signed with the private key.</td></tr></tbody></table>

```
function withdraw(address paymentId, bytes memory signature) public;
```

### cancel

Payments cancel function.

<table><thead><tr><th width="301.8711599216471">Parameter name</th><th>Annotation</th></tr></thead><tbody><tr><td>_paymentId</td><td>The ID of the payment to cancel.</td></tr></tbody></table>

Allows only creator of payment to cancel.

```
function cancel(address paymentId) public;
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gooddollar.org/for-developers/core-contracts/onetimepayments.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
