To record notes you need to make a transaction and pay the fee, you can send to same address 1 microAlgo.
1- If you haven’t created a Wallet yet, use the code:
$algorand_kmd = new Algorand_kmd('{kmd-token}',"localhost",7833);
#Create Wallet same as cli: goal wallet new
$params['params']=array(
"wallet_name" => "algotest",
"wallet_password" => "password",
"wallet_driver_name" => "sqlite",
);
$return=$algorand_kmd->post("v1","wallet",$params);
//Will return the Wallet ID
/* Response:
{
"wallet": {
"driver_name": "sqlite",
"driver_version": 1,
"id": "8abb280fc4d974be077b3333dc9dea34", <<<< HERE
"mnemonic_ux": false,
"name": "algotest",
"supported_txs": [
"pay",
"keyreg"
]
}
*/
2- To get your wallet ID again:
#Wallet List same as cli: goal wallet list
$return=$algorand_kmd->get("v1","wallets");
3- Create an account (key address):
$algorand_kmd = new Algorand_kmd('{kmd-token}',"localhost",7833);
#Wallet Init to get the handle token
$params['params']=array(
"wallet_id" => "8abb280fc4d974be077b3333dc9dea34",
"wallet_password" => "password",
);
$return=$algorand_kmd->post("v1","wallet","init",$params);
$return_array=json_decode($return['response']);
$wallet_handle_token=$return_array->wallet_handle_token;
#Generate a key
$params['params']=array(
"display_mnemonic" => false,
"wallet_handle_token" => $wallet_handle_token
);
$return=$algorand_kmd->post("v1","key",$params);
/* Response
{
"address": "NBUTVWA7MYHLORN7SM73JT2I2S2MTXO2FPXOIUDXOB2DS36SFVGOQTI3AA"
}
*/
4- Transfer Algos to the newly created address.
The scripts above, you only need execute one time. To create the transaction use the code below:
$algorand_kmd = new Algorand_kmd('{kmd-token}',"localhost",7833);
#Wallet Init to get the handle token
$params['params']=array(
"wallet_id" => "8abb280fc4d974be077b3333dc9dea34",
"wallet_password" => "password",
);
$return=$algorand_kmd->post("v1","wallet","init",$params);
$return_array=json_decode($return['response']);
$wallet_handle_token=$return_array->wallet_handle_token;
$transaction=array(
"txn" => array(
"type" => "pay", //Tx Type
"fee" => 1000, //Fee
"fv" => 13636245, //First Valid
"gen" => "mainnet-v1.0", // GenesisID
"gh" => "YBQ4JWH4DW655UWXMBF6IVUOH5WQIGMHVQ333ZFWEC22WOJERLPQ=", //Genesis Hash
"lv" => 13637245, //Last Valid
"note" => "Tests", //You note
"snd" => "NBUTVWA7MYHLORN7SM73JT2I2S2MTXO2FPXOIUDXOB2DS36SFVGOQTI3AA", //Sender
"rcv" => "NBUTVWA7MYHLORN7SM73JT2I2S2MTXO2FPXOIUDXOB2DS36SFVGOQTI3AA", //Receiver
"amt" => 1000, //Amount
),
);
#Sign Transaction
$params['params']=array(
"transaction" => $algorand_kmd->txn_encode($transaction),
"wallet_handle_token" => $wallet_handle_token,
"wallet_password" => "password",
);
$return=$algorand_kmd->post("v1","transaction","sign",$params);
$r=json_decode($return['response']);
$txn=base64_decode($r->signed_transaction);
#Broadcasts a raw transaction to the network.
$algorand = new Algorand_algod('4820e6e45f339e0026eaa2b74c2aa7d8735cbcb2db0cf0444fb492892e1c09b7',"localhost",53898); //Start Algod services
$params['transaction']=$txn;
$return=$algorand->post("v2","transactions",$params);
if(!empty($return['response']->txId)){
$txId=$return['response']->txId;
echo "txId: $txId";
}