This repository demonstrates how to use Alchemy's Java Signer SDK to authenticate users and sign real transactions on the Ethereum Sepolia test network.
<dependency>
<groupId>com.alchemy.accountkit</groupId>
<artifactId>signer-sdk</artifactId>
<version>0.1.0-alpha-7880b179</version>
</dependency>
-
Create an Alchemy application
Go to the Alchemy dashboard and create a new application with both Account Kit and Node API enabled. -
Insert your API key
InDemoApplication
, replace every instance of"<REPLACE_WITH_API_KEY>"
with the API key obtained from Step 1. -
Onboard your OIDC connector
Contact the Alchemy team to register (onboard) your OIDC connector. -
Update OIDC configuration
InDemoApplication
, replace every//CHANGE-ME
placeholder with the relevant OIDC setup. Ensure that you can obtain a valid JWT token from your OIDC connector, and note that the JWT’s nonce must besha256(tekManager.publicKey())
. -
Start the project
See Start the project below.
mvn spring-boot:run
DemoApplication
defines two primary endpoints: /user
and /sign
. Both are GET endpoints.
You can test the endpoints using tools such as curl or Postman.
When you call /user
(with no parameters), the demo:
- Generates a TekManager object for each end user.
- Requests a JWT from your OIDC provider.
- Authenticates with Alchemy using
signerClient.authenticateWithJWT
. - Returns a stamper that can be used to stamp data and exchange it for a real signature.
Example Request (curl):
curl -X GET "http://localhost:8888/user"
Example Response:
{
"credentialBundle": {
"bundlePrivateKey": "MEECAQAwEwYHKoZIzj0CAQYIKoZIzj0DAQcEJzAlAgEBBCBaTF44aNZtZsBv/hBFjp9eNeRREOf05hyaOMoqtLRArA==",
"bundlePublicKey": "A5Kc3SmkRr8Idoyf/mqSL97MKsXR5j0E4pmwsrcgb1oH"
},
"user": {
"email": null,
"userId": "dfc453cc-df55-4716-8a15-61492b4f0fcc",
"orgId": "e34032d8-d42f-4980-9f07-b7b40f765789",
"address": "0x7f9689C78B86B289531f4dA0abf686e55F20A744",
"solanaAddress": "7YnJFzxkkEiRMxdRSz4cd4FUCidKQv2JfgD6QaGpCLhH"
}
}
Important:
Before you call /sign
, make sure you fund the returned address
with some test ETH. You can use the Alchemy Sepolia faucet.
Use /sign
to sign and broadcast an Ethereum (Sepolia) transaction for the user you retrieved in /user
.
Query Parameter:
userId
: TheuserId
from the/user
endpoint’s response.
What Happens:
- The application creates a sample Eth-Sepolia transaction.
- Calls
signerClient.signEthTx
using the stamper from/user
to sign the transaction. - Broadcasts the transaction to the Sepolia test network.
Example Request (curl):
curl -X GET "http://localhost:8888/sign?userId=dfc453cc-df55-4716-8a15-61492b4f0fcc"
Example Response (Transaction Hash):
0x9ef79e1711c6f08a625bc03dc7766f30c75069dc3ce2b18db6f860ed80b4d3a9
You can track the transaction status on Sepolia Etherscan by appending your returned hash to the Etherscan URL, for example:
https://sepolia.etherscan.io/tx/0x9ef79e1711c6f08a625bc03dc7766f30c75069dc3ce2b18db6f860ed80b4d3a9
A sample transaction screenshot:
Questions or Issues?
If you run into any problems or need help, please contact the Alchemy team or open an issue on this repository.