Skip to content

CEP-3009: Transfer with Authorization#100

Open
zie1ony wants to merge 2 commits into
casper-network:masterfrom
odradev:cep3009
Open

CEP-3009: Transfer with Authorization#100
zie1ony wants to merge 2 commits into
casper-network:masterfrom
odradev:cep3009

Conversation

@zie1ony
Copy link
Copy Markdown
Contributor

@zie1ony zie1ony commented May 12, 2026

@zie1ony zie1ony changed the title CEP3009: Transfer with Authorization CEP-3009: Transfer with Authorization May 12, 2026
Copy link
Copy Markdown

@davidatwhiletrue davidatwhiletrue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zie1ony see my comments.

from Ethereum and is adapted to Casper's native multi-scheme signatures
(ed25519, secp256k1). A token holder signs a typed message authorizing a
specific transfer (recipient, amount, validity window, unique nonce), and
any party may submit that signature to execute the transfer on the
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true for transfer_with_authorization. Not for receive_with_authorization.

Comment thread text/3009-transfer-with-authorization.md
- three new mutating entry points (`transfer_with_authorization`,
`receive_with_authorization`, `cancel_authorization`),
- one read entry point (`authorization_state`),
- the EIP-712 typed data definitions for the three structs above,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'...and the domain separator'

Below definitions use Rust syntax, but they are not Rust specific. `Bytes`
denotes the Casper `bytesrepr::Bytes` type; nonces are exactly 32 bytes.

### Entrypoint interface
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Entry point' with a space

///
/// The signature is verified against the `ReceiveWithAuthorization`
/// typed payload — a distinct typehash from
/// `transfer_with_authorization`, so a signature for one cannot be
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TransferWithAuthorization the type, not the entry point.

Comment thread text/3009-transfer-with-authorization.md
- `valid_before` encoded as a `u64` left-padded to 32 bytes,
- `nonce` as a 32-byte value (right-padded with zeros if shorter).

Note: `validAfter` and `validBefore` appear as `uint256` in the type
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this note needed? If uint256 is equivalent, should we keep it simple and just write “validAfter encoded as a uint256“ above?


Encoded message data:

- `authorizer` encoded as EIP-712 `address` (32 bytes, big-endian, left-padded),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as for from and to in TransferWithAuthorization.

InvalidCaller = 37_005,
/// The `(authorizer, nonce)` pair targeted by `cancel_authorization`
/// is already used or canceled.
AuthorizationUsed = 37_006,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using this error in transfer_with_authorization and receive_with_authorization and remove NonceAlreadyUsed.

The chain name used in the EIP-712 domain separator is stored in the
contract's named keys:

- The chain name is stored under the key `chain_name` with the type
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend to use CAIP-2 chain ids (e.g.: casper:casper, casper:casper-test, or casper:casper-net-1).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not "recommend". Definitely use CAIP-2 chain ids...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants