在Hello Aleo这篇教程中 Your First Aleo Program :Make a Transfer, 我居然就跑不过
Hello Aleo Instructions | Welcome to Aleo Documentation
power Shell 命令行输入参数, 如果使用cmd 需要放在一行里才行
aleo run transfer_amount "{
owner: aleo1x5nz5u4j50w482t5xtqc3jdwly9s8saaxlgjz0wvmuzmxv2l5q9qmypx09.private,
gates: 0u64.private,
amount: 50u64.private
}" aleo1h3gu7fky36y8r7v2x9phc434fgf20g8qd7c7u45v269jfw6vmugqjegcvp 10u64
报错:
error: Invalid value "{\nowner: aleo1x5nz5u4j50w482t5xtqc3jdwly9s8saaxlgjz0wvmuzmxv2l5q9qmypx09.private,\ngates: 0u64.private,\namount: 50u64.private\n}" for '<INPUTS>...': Failed to parse string. Parsing Error: VerboseError { errors: [("\n}", Nom(Tag)), ("{\nowner: aleo1x5nz5u4j50w482t5xtqc3jdwly9s8saaxlgjz0wvmuzmxv2l5q9qmypx09.private,\ngates: 0u64.private,\namount: 50u64.private\n}", Nom(Alt))] }
这个报错非常难以理解, 经过尝试, .private 的点在解析的时候是有问题的 把 .priavte去掉, 报错内容变了,变成 Expected a record input, found a plaintext input , 解析不出来record了
这里面 record的参数如何输入呢? 有待进一步学习, 有知道的朋友感谢留言
一个转账的样例源码
// The 'foo.aleo' program.
program foo.aleo;
record token:
owner as address.private;
gates as u64.private;
amount as u64.private;
function transfer_amount:
// sender token record
input r0 as token.record;
// receiver address
input r1 as address.private;
// amount to transfer
input r2 as u64.private;
// final balance of sender
sub r0.amount r2 into r3;
// final balance of receiver
add 0u64 r2 into r4;
// sender token record after the transfer
cast r0.owner r0.gates r3 into r5 as token.record;
// receiver token record after the transfer
cast r1 0u64 r4 into r6 as token.record;
// sender new token record
output r5 as token.record;
// receiver new token record
output r6 as token.record;