| Crates.io | corevm-guest |
| lib.rs | corevm-guest |
| version | 0.1.22 |
| created_at | 2025-04-15 13:23:43.914488+00 |
| updated_at | 2025-05-30 18:58:11.897931+00 |
| description | API/SDK for CoreVM guest programs |
| homepage | |
| repository | https://github.com/paritytech/polkajam.git |
| max_upload_size | |
| id | 1634426 |
| size | 16,364 |
⚠️ CoreVM API is subject to change.
CoreVM programs have single entry-point called main with index = 0 (the default).
The simplest program looks like the following.
#![no_std]
#![no_main]
#[polkavm_derive::polkavm_export]
extern "C" fn main() -> u64 {
0
}
CoreVM programs produce output into one of the output streams. Currently console and video streams are available. The simplest program that outputs "Hello world" to the console output stream is shown below.
#![no_std]
#![no_main]
use corevm_guest::println;
#[polkavm_derive::polkavm_export]
extern "C" fn main() -> u64 {
println!("Hello world");
0
}
Copying out the data is an atomic operation:
the array passed to e.g. yield_console_data is either fully copied or not copied at all.
If the array can't be copied, the program execution is suspended, and
the continuation is possible via creating another work package.
Here is the example program written in C.
#include <stdint.h>
#include "corevm_guest.h"
POLKAVM_EXPORT(uint64_t, ext_main);
uint64_t ext_main() {
corevm_printf("Hello world\n");
return 0;
}