1. Go to this page and download the library: Download viz-blockchain/viz-php-lib library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
viz-blockchain / viz-php-lib example snippets
vate_key=new VIZ\Key('b9f3c242e5872ac828cf2ef411f4c7b2a710bd9643544d735cc115ee939b3aae');
print 'Private key from hex: '.$private_key->hex.PHP_EOL;
print 'Private key WIF: '.$private_key->encode().PHP_EOL;
$data='Hello VIZ.World! '.date('d.m.Y H:i:s');
print 'Data for signing: '.$data.PHP_EOL;
$signature=$private_key->sign($data);
if(false===$signature){
print 'Canonical signature was not found, please try again.';
}
else{
print 'Signature: '.$signature.PHP_EOL;
$public_key=$private_key->get_public_key();
$recovered_public_key=$public_key->recover_public_key($data,$signature);
print 'Recovered public key from signature: '.$public_key->encode().PHP_EOL;
if($public_key){
print 'Public key from private: '.$public_key->encode().PHP_EOL;
print 'Verify signature status for same data: '.var_export($public_key->verify($data,$signature),true).PHP_EOL;
print 'Verify signature status for other data: '.var_export($public_key->verify('Bye VIZ.World!',$signature),true).PHP_EOL;
}
}
unt='test';
$private_key='5K...';//regular
$tx=new VIZ\Transaction('https://node.viz.plus/',$private_key);
$tx_data=$tx->custom([],[$account],'test','{"msg":"testing viz-php-lib custom operation"}');
var_dump($tx_data);
$tx->api->return_only_result=false;
//second attribute is synchronous, if setted then return block num where transaction was witnessed
$tx_status=$tx->execute($tx_data['json'],true);
var_dump($tx_status);
unt='test';
$private_key='5K...';//regular
$tx=new VIZ\Transaction('https://api.viz.world/',$private_key);
$fee='0.000 VIZ';
$delegation='10.000000 SHARES';
//you can set any authority as simple string with encoded public key
$master='VIZ7RXhpaw8SbedSp84EqMGGzeBZgAPLEn7D6kQhJu8bMMvUKtuxk';//5JRd4Toy8cmDr15qEtZieqAgbg3qQMU6n8cPC1Las2hBah46tr1
$active='VIZ7H8S8rHkKQkX8bSUpDtBAwy8tTphq2NH7ZRv1dcCvk1Cjz38nK';//5JvgdGsA5M8rZ9oY2p7qcKkexG1kWqN2jQcQ6afEPCqQXrKTsbS
//or make full authority struct (if you need more flexibility)
$regular=[
//'weight_threshold'=>1,//can be empty if weight_threshold=1
'account_auths'=>[
['on1x',1]
],
'key_auths'=>[
['VIZ5bGNeJPjoDdZTEK3LSMUfP21gcBH34AdMPHpvQymuYMk2YMbsB',1],//5HuHKQhiiAAAp7zMCgRpCCyv8hramEmzAzDUagrhMkTWDhyVtK6
['VIZ5jWA94PYBanGSPhTyWrwvT8RAJcnB7onXGvK5DnzbxB6874yap',1]//5KESchwZvs67C4Xz5SQQ1ea4N9rZR67NEvi6yemWpSYoKo9eTrM
]
];
//you need manually check public keys sorting in key_auths or node will refuse the transaction
$memo_key='VIZ1111111111111111111111111111111114T1Anm';//can be empty key
$json_metadata='';
$referrer='';
$new_account_name='test-lib';
$tx_data=$tx->account_create($fee,$delegation,$account,$new_account_name,$master,$actove,$regular,$memo_key,$json_metadata,$referrer);
var_dump($tx_data);
$tx->api->return_only_result=false;
$tx_status=$tx->execute($tx_data['json']);
var_dump($tx_status);
unt='test';
$private_key='5K...';//regular
//$endpoint,$key,$account,$text,$reply=false,$share=false,$beneficiaries=false,$loop=false
$status=VIZ\Utils::voice_text('https://api.viz.world/',$private_key,$account,'Test from viz-php-lib');
var_dump($status);
unt='test';
$private_key='5K...';//regular
$markdown='Well, Voice protocol markdown have **bold**, __italic__, ~~stroke~~ and `code`
## Headers 2
### And 3
Also we got:
> Quotes and
>> Second style for citation
Support lists:
* Unordered
* as ordinary
* items
And ordered, ofc:
*n Yes
*n it is!
After all, simple images:

Paragraph
with
multiline
...and #en #example tags support :)';
//$endpoint,$key,$account,$title,$markdown,$description,$image,$reply=false,$share=false,$beneficiaries=false,$loop=false,$synchronous=false
$status=VIZ\Utils::voice_publication('https://api.viz.world/',$private_key,$account,'Test publication from viz-php-lib',$markdown);
var_dump($status);
unt='test';
$private_key='5K...';
$text='Test text and event from viz-php-lib';
//create Voice object with text type (last attribute is synchronous that returns block num where is transaction was witnessed)
$object_block_num=VIZ\Utils::voice_text('https://api.viz.world/',$private_key,$account,$text,false,false,false,false,true);
print 'Object: viz://@'.$account.'/'.$object_block_num.'/';
//hide event
$event_block_num=VIZ\Utils::voice_event('https://api.viz.world/',$private_key,$account,'h',false,$object_block_num,false,false,true);
print 'Hide event for this object: viz://@'.$account.'/'.$object_block_num.'/?event='.$event_block_num;
unt='test';
$private_key='5K...';
$max_size_limit=65280;
$part_size=1024*10;//10Kb
$long_text='...';//long text more that $max_size_limit bytes
//create Voice object with text type (last attribute is synchronous that returns block num where is transaction was witnessed)
$tx_prepare=VIZ\Utils::voice_text('https://api.viz.world/',$private_key,$account,$long_text,false/*reply*/,false/*share*/,false/*beneficiaries*/,false/*loop*/,true/*synchronous*/,true/*raw tx*/);
$tx_length=strlen($tx_prepare['data'])/2;
if($tx_length<$max_size_limit){
$object_block_num=VIZ\Utils::voice_text('https://api.viz.world/',$private_key,$account,$long_text,false/*reply*/,false/*share*/,false/*beneficiaries*/,false/*loop*/,true/*synchronous*/,false/*raw tx*/);
if($object_block_num){
print 'Object: viz://@'.$account.'/'.$object_block_num.'/';
}
else{
print 'Object error';
}
}
else{
$tx_diff=$tx_length-$max_size_limit;
$parts_count=ceil($tx_diff / $part_size);
$markdown_length=mb_strlen($long_text);
$main_part_length=$markdown_length-($parts_count*$part_size);
if($main_part_length<0){
$main_part_length=$part_size;
}
$main_part=mb_substr($long_text,0,$main_part_length);
$secondary_part=mb_substr($long_text,$main_part_length);
$object_block_num=VIZ\Utils::voice_text('https://api.viz.world/',$private_key,$account,$main_part,false/*reply*/,false/*share*/,false/*beneficiaries*/,false/*loop*/,true/*synchronous*/,false/*raw tx*/);
if($object_block_num){
print 'Main object: viz://@'.$account.'/'.$object_block_num.'/'.PHP_EOL;
//add event
$event_block_num=VIZ\Utils::voice_event('https://api.viz.world/',$private_key,$account,'a',false,$object_block_num,false/*data_type*/,['t'=>$secondary_part]/*data*/,true/*synchronous*/,false/*raw tx*/);
if($event_block_num){
print 'Add event for this object: viz://@'.$account.'/'.$object_block_num.'/?event='.$event_block_num;
}
else{
print 'Event error';
}
}
else{
print 'Object error';
}
}
t=new VIZ\Agent('https://api.viz.world/');
//the key recovered from the request signature
$verdict=$agent->check('altbettor','VIZ7iiYUk6hFuieveBJcTVTV33aNuC2vZauXuYc9Hki3moxsm9WXe','transfer');
if($verdict['allowed']){
print 'allowed by '.$verdict['source'];//'authority' or 'agent'
}
else{
print 'denied';
}
$rows=$agent->get('altbettor');//every agent of the principal as the node returns them
$row=$agent->find('altbettor','VIZ7iiYUk6hFuieveBJcTVTV33aNuC2vZauXuYc9Hki3moxsm9WXe');//live row, or false
=new VIZ\Auth('https://api.viz.world/','wallet.viz.world','auth','regular',60,'wallet');
//6th argument = our addon scope; omit it and agent keys are not accepted here
if($auth->check($data,$signature)){
//the key belongs to the authority of the account, or is its agent scoped to 'wallet'
}
tor='test';
$active_key='5K...';//active
$tx=new VIZ\Transaction('https://api.viz.world/',$active_key);
//create a binary (CPMM) market, self-oracle, seeded with 100 VIZ liquidity
$tx_data=$tx->pm_create_market(
$creator,$creator,0/*binary*/,['Yes','No'],'Will X happen by 2026?',
300/*oracle_fee bp*/,'0.000 VIZ',100/*creator_fee bp*/,200/*lp_fee bp*/,
'100.000 VIZ',0/*lmsr_b, 0 for binary*/,
'2026-08-01T00:00:00'/*betting_expiration*/,'2026-08-02T00:00:00'/*result_expiration*/
);
$tx_status=$tx->execute($tx_data['json']);
//place an instant bet on side 0 (binary uses outcome_index -1)
$bet=$tx->pm_place_bet($creator,5/*market_id*/,0/*side*/,-1/*outcome_index*/,'10.000 VIZ');
$tx->execute($bet['json']);
$salt='cafe1234';
$commitment=$tx->pm_commitment(5/*market_id*/,'alice',0/*side*/,-1/*outcome_index*/,10000/*amount*/,0/*min_tokens*/,$salt);
//no_reveal_fee_percent MUST equal median(pm_commit_no_reveal_penalty_percent)
$commit=$tx->pm_commit_bet('alice',5,$commitment,'10.000 VIZ',2000);
$tx->execute($commit['json']);
//...later, within the reveal window, re-supply the same values + salt:
$reveal=$tx->pm_reveal_bet('alice',$commit_id,0,-1,'10.000 VIZ',$salt,0);
$tx->execute($reveal['json']);
new VIZ\JsonRPC('https://api.viz.world/');
$market=$api->execute_method('get_market',[5]);
$active=$api->execute_method('list_markets',[1/*status active*/,0/*from*/,100/*limit*/]);
$full=$api->execute_method('get_market_full',[5,'alice']);//one-call market detail view
$props=$api->execute_method('get_pm_chain_properties');//live median governance params
$kline=$api->execute_method('get_market_kline',[5,0,1000]);//chart series (offset-from-newest)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.