|
1 | | -# convex-java |
2 | | -Java client library for Convex |
| 1 | +# Convex Java SDK |
3 | 2 |
|
4 | | -## About |
| 3 | +[](https://search.maven.org/search?q=world.convex) |
| 4 | +[](https://javadoc.io/doc/world.convex/convex-java) |
5 | 5 |
|
6 | | -Convex is an open, decentralised technology for the Internet of Value. Java is one of the world's leading programming languages, especially in the realm of business and finance. |
| 6 | +The official Java SDK for building applications on the [Convex](https://convex.world) network. |
7 | 7 |
|
8 | | -`convex-java` provides everything Java developers need to access Convex and utilise all of its capabilities from their own applications. |
| 8 | +## Installation |
9 | 9 |
|
10 | | -## Usage |
| 10 | +### Maven |
11 | 11 |
|
12 | | -You will need a connection to a peer on the Convex Network. Peers are servers which participate in the maintaining consensus on the Convex Network, by executing the CPoS consensus algorithm and validating transactions. It is easiest if you simply use the free public peer available at `https://convex.world`. |
| 12 | +```xml |
| 13 | +<dependency> |
| 14 | + <groupId>world.convex</groupId> |
| 15 | + <artifactId>convex-java</artifactId> |
| 16 | + <version>0.8.2</version> |
| 17 | +</dependency> |
| 18 | +``` |
| 19 | + |
| 20 | +### Gradle |
| 21 | + |
| 22 | +```groovy |
| 23 | +implementation 'world.convex:convex-java:0.8.2' |
| 24 | +``` |
| 25 | + |
| 26 | +## Quick Start |
| 27 | + |
| 28 | +### Connect to the Network |
13 | 29 |
|
14 | 30 | ```java |
| 31 | +import convex.java.Convex; |
| 32 | + |
| 33 | +// Connect to the public test network |
15 | 34 | Convex convex = Convex.connect("https://convex.world"); |
16 | 35 | ``` |
17 | 36 |
|
18 | | -To utilise the network, you will need an account with available funds. On the Test Network, you can obtain one by requesting a new account with free balance (up to 10,000,000 Convex copper coins). This should be enough for most simple testing. |
| 37 | +### Create an Account |
19 | 38 |
|
20 | 39 | ```java |
21 | | -convex.useNewAccount(10000000); |
| 40 | +// Request a new account with test funds (up to 10,000,000 copper coins) |
| 41 | +convex.useNewAccount(10_000_000); |
| 42 | + |
| 43 | +// Access your key pair (required for signing transactions) |
| 44 | +AKeyPair keyPair = convex.getKeyPair(); |
22 | 45 | ``` |
23 | 46 |
|
24 | | -`convex-java` will automatically generate a new cryptographic key pair to secure your new account. Having a valid key pair for the account is the *only way* to successfully submit transactions for that Account on the Convex Network. If you want to access the key pair, you can use: |
| 47 | +### Execute Queries |
| 48 | + |
| 49 | +Queries are read-only operations that don't modify state: |
25 | 50 |
|
26 | 51 | ```java |
27 | | -convex.getKeyPair() |
| 52 | +// Query the current balance |
| 53 | +ACell result = convex.query("*balance*"); |
28 | 54 | ``` |
29 | 55 |
|
| 56 | +### Submit Transactions |
30 | 57 |
|
| 58 | +Transactions modify on-chain state and require a funded account: |
31 | 59 |
|
| 60 | +```java |
| 61 | +// Transfer funds to another account |
| 62 | +ACell result = convex.transact("(transfer #42 1000000)"); |
32 | 63 |
|
| 64 | +// Deploy a smart contract |
| 65 | +ACell result = convex.transact("(deploy '(do (defn greet [name] (str \"Hello, \" name))))"); |
| 66 | +``` |
33 | 67 |
|
34 | | -## Installation and Configuration |
| 68 | +## Key Concepts |
35 | 69 |
|
36 | | -You can clone this repository and run `mvn install` to get a working local version. This is recommended for developers who wish to use early snapshot versions or contribute to `convex-java` as an open source project. |
| 70 | +| Concept | Description | |
| 71 | +|---------|-------------| |
| 72 | +| **Account** | Self-sovereign identity on Convex, identified by address (e.g., `#42`) | |
| 73 | +| **Key Pair** | Ed25519 cryptographic keys for signing transactions | |
| 74 | +| **Query** | Read-only operation, free to execute | |
| 75 | +| **Transaction** | State-changing operation, consumes juice (gas) | |
| 76 | +| **Convex Lisp** | On-chain programming language for smart contracts | |
37 | 77 |
|
38 | | -`convex-java` is also available as a Maven dependency. |
| 78 | +## Building from Source |
39 | 79 |
|
| 80 | +```bash |
| 81 | +git clone https://github.com/Convex-Dev/convex.git |
| 82 | +cd convex |
| 83 | +mvn install -pl convex-java -am |
40 | 84 | ``` |
41 | | -<dependency> |
42 | | - <groupId>world.convex</groupId> |
43 | | - <artifactId>convex-java</artifactId> |
44 | | - <version>0.0.1</version> |
45 | | -</dependency> |
46 | | -``` |
| 85 | + |
| 86 | +## Resources |
| 87 | + |
| 88 | +- [Convex Documentation](https://docs.convex.world) |
| 89 | +- [Javadoc API Reference](https://javadoc.io/doc/world.convex/convex-java) |
| 90 | +- [GitHub Repository](https://github.com/Convex-Dev/convex) |
| 91 | +- [Discord Community](https://discord.com/invite/xfYGq4CT7v) |
47 | 92 |
|
48 | 93 | ## License |
49 | 94 |
|
50 | | -Copyright 2021-203 The Convex Foundation and Contributors |
| 95 | +Copyright 2021-2025 The Convex Foundation and Contributors |
51 | 96 |
|
52 | | -Code in convex-java is provided under the Convex Public License |
| 97 | +Code in convex-java is provided under the [Convex Public License](../LICENSE.md). |
0 commit comments