Crates.io | aleo-development-server |
lib.rs | aleo-development-server |
version | 0.5.5 |
source | src |
created_at | 2023-04-22 01:31:53.157772 |
updated_at | 2023-08-10 22:09:29.628704 |
description | A REST API server for local or remote Aleo development |
homepage | https://aleo.org |
repository | https://github.com/AleoHQ/sdk |
max_upload_size | |
id | 845770 |
size | 172,032 |
The Aleo Development Server provides REST endpoints that allow developers to send the necessary data needed to create program deployments and executions to the Aleo network. Currently there are three endpoints:
/deploy
- Create a program deployment/execute
- Create a program execution/transfer
- Create a transfer of Aleo creditsThe development server can be installed with:
cargo install aleo-development-server
- Install from crates.io
cargo install --path . --locked
- Install from source
Once installed the following command can be used to start the server:
aleo-develop start
- Start the server at 0.0.0.0:4040
(by default the server sends transactions to the Aleo testnet3 network)
aleo-develop start --help
- Show all available options for configuring the server
The server can be started with an encrypted private key. If this option is used, the server will look for a password field in the body of incoming requests. If a password is provided (and the password is correct), the server will decrypt the private key and use it to build and send the transaction to the network. This mode of operation can be invoked with:
aleo-develop start --key-ciphertext <encrypted_private_key>
Once started, the endpoints have the following options. All requests should be sent as a POST request with a json body.
A javascript client for this server is available in the Aleo SDK
\develop
program
: Text representation of the program to be deployedfee
: Required fee to be paid for the program deploymentprivate_key
: Optional private key of the user who is deploying the programpassword
: If the development server is started with an encrypted private key, the password will decrypt the private keyfee_record
: Optional record in text format to be used for the fee. If not provided, the server will search the network for a suitable record to pay the fee.returns
: The transaction ID of the deployment transaction if successful\execute
program_id
The program ID of the program to be executed (e.g. hello.aleo)program_function
The function to execute within the program (e.g. hello)fee
Optional fee to be paid for the transfer, specify 0 for no feeinputs
Array of inputs to be passed to the programprivate_key
Optional private key of the user who is executing the programpassword
: If the development server is started with an encrypted private key, the password will decrypt the private keyfee_record
: Optional record in text format to be used for the fee. If not provided, the server will search the network for a suitable record to pay the feereturns
: The transaction ID of the execution transaction if successful\transfer
amount
The amount of credits to be sent (e.g. 1.5)fee
Optional Fee to be paid for the transfer, specify 0 for no feerecipient
The recipient of the transferprivateKey
Optional private key of the user who is sending the transferpassword
: If the development server is started with an encrypted private key, the password will decrypt the private keyamount_record
Optional record in text format to be used to fund the transfer. If not provided, the server will search the network for a suitable record to fund the amountfee_record
Optional record in text format to be used for the fee. If not provided, the server will search the network for a suitable record to pay the fee
@returns {string | Error} The transaction ID of the execution transaction if successfulExample curl requests for the above endpoints:
## Deploy a program
curl -X POST -H "Content-Type: application/json" \
-d '{
"program": "program hello.aleo;\n\nfunction hello:\n input r0 as u32.public;\n input r1 as u32.private;\n add r0 r1 into r2;\n output r2 as u32.private;\n",
"fee": 100000,
"private_key": "APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH"
}' \
http://0.0.0.0:4040/testnet3/deploy
## Execute a program
curl -X POST -H "Content-Type: application/json" \
-d '{
"program_id": "hello.aleo",
"program_function": "hello",
"inputs": ["5u32", "5u32"],
"private_key": "APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH",
"fee": 0
}' \
http://0.0.0.0:4040/testnet3/execute
## Create a value transfer
curl -X POST -H "Content-Type: application/json" \
-d '{
"amount": 1000,
"fee": 0,
"recipient": "aleo1trtljxr7rw6cn368v2pslnxgl2vzk9pgfunev59k53x645hvrygs5v4f2e",
"private_key": "APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH"
}' \
http://0.0.0.0:4040/testnet3/transfer
This API of this server is currently under active development and is expected to change in the future in order to provide a more streamlined experience for program execution and deployment.