X402 hands-on

How it works ?

Manage wallet & funds

You can generate a key pair with the command:

For the sake of this document, we will use the following key pairs:

Client (buyer) Address: 0x2980bc24bBFB34DE1BBC91479Cb712ffbCE02F73 Private key: 0x9d2675820d55300a05c8991df217a619bcfdc86e2fd91e56443dbbcf159337fd

Server (seller) Address: 0x7553F6FA4Fb62986b64f79aEFa1fB93ea64A22b1 Private key: 0xf4f7e165433421377856179c698aa387bd8f872657977bd8fa6d62604f41773c

You can add funds to your wallet using the CDP faucet.

Getting ready

You need to install Foundry (explained in the README) and those tools:

Then, you can download the sources:

Make it work

Coinbase provides an example server here.

Edit .env and have those two lines to ADDRESS=0x2980bc24bBFB34DE1BBC91479Cb712ffbCE02F73.

Then you can run the server:

Now, to run the server:

Now, we will run a client.

Edit .env and have those two lines to

You will get a message like this:

The transaction can be seen here.

Last updated