RIDE ๋ฐ RIDE4DAPPS์—์„œ Waves ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์›๋‹ˆ๋‹ค. 2๋ถ€(DAO - ๋ถ„์‚ฐํ˜• ์ž์œจ ์กฐ์ง)

RIDE ๋ฐ RIDE4DAPPS์—์„œ Waves ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์›๋‹ˆ๋‹ค. 2๋ถ€(DAO - ๋ถ„์‚ฐํ˜• ์ž์œจ ์กฐ์ง)

์•ˆ๋…•ํ•˜์‹ญ๋‹ˆ๊นŒ!

ะ’ ์ฒซ ๋ฒˆ์งธ ๋ถ€๋ถ„์—์„œ๋Š” dApp(๋ถ„์‚ฐํ˜• ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜)์„ ์ƒ์„ฑํ•˜๊ณ  ์ž‘์—…ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ž์„ธํžˆ ์‚ดํŽด๋ณด์•˜์Šต๋‹ˆ๋‹ค. ์›จ์ด๋ธŒ ๋ผ์ด๋“œ IDE.

์ด์ œ ๋ถ„ํ•ด๋œ ๊ฒƒ์„ ์กฐ๊ธˆ ํ…Œ์ŠคํŠธํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์˜ˆ.

3๋‹จ๊ณ„. dApp ๊ณ„์ • ํ…Œ์ŠคํŠธ

RIDE ๋ฐ RIDE4DAPPS์—์„œ Waves ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์›๋‹ˆ๋‹ค. 2๋ถ€(DAO - ๋ถ„์‚ฐํ˜• ์ž์œจ ์กฐ์ง)

Alice์™€ ๊ด€๋ จํ•˜์—ฌ ์–ด๋–ค ๋ฌธ์ œ๊ฐ€ ์ฆ‰์‹œ ๋ฐœ์ƒํ•ฉ๋‹ˆ๊นŒ? dApp ๊ณ„์ •?
์ฒซ ๋ฒˆ์งธ :
Boob๊ณผ Cooper๋Š” ์‹ค์ˆ˜๋กœ ์ผ๋ฐ˜ ๊ณ„์ •์„ ์‚ฌ์šฉํ•˜์—ฌ dApp ์ฃผ์†Œ๋กœ ์ž๊ธˆ์„ ๋ณด๋‚ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด์ „ ๊ฑฐ๋ž˜์— ๋‹ค์‹œ ์•ก์„ธ์Šคํ•  ์ˆ˜ ์—†๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

๋‘˜์งธ :
์šฐ๋ฆฌ๋Š” Boob ๋ฐ/๋˜๋Š” Cooper์˜ ์Šน์ธ ์—†์ด Alice๊ฐ€ ์ž๊ธˆ์„ ์ธ์ถœํ•˜๋Š” ๊ฒƒ์„ ์–ด๋–ค ์‹์œผ๋กœ๋“  ์ œํ•œํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๊ฒ€์ฆ์— ์ฃผ์˜ํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค. Alice์˜ ๋ชจ๋“  ๊ฑฐ๋ž˜๊ฐ€ ์‹คํ–‰๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

Alice๋ฅผ ๊ธˆ์ง€ํ•˜์—ฌ ๋‘ ๋ฒˆ์งธ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜์ž ์ด์ „ ์—…๋ฌด. ์ˆ˜์ •๋œ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๋ฐฐํฌํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.
RIDE ๋ฐ RIDE4DAPPS์—์„œ Waves ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์›๋‹ˆ๋‹ค. 2๋ถ€(DAO - ๋ถ„์‚ฐํ˜• ์ž์œจ ์กฐ์ง)
๏ฟผ
์šฐ๋ฆฌ๋Š” dApp Alice์™€ ๊ทธ๋…€์˜ ์„œ๋ช…์—์„œ ์ฝ”์ธ์„ ์ถœ๊ธˆํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.
RIDE ๋ฐ RIDE4DAPPS์—์„œ Waves ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์›๋‹ˆ๋‹ค. 2๋ถ€(DAO - ๋ถ„์‚ฐํ˜• ์ž์œจ ์กฐ์ง)

์ฒ ํšŒ๋ฅผ ํ†ตํ•ด ์ฒ ํšŒ๋ฅผ ์‹œ๋„ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

broadcast(invokeScript({dappAddress: address(env.accounts[1]), call:{function:"withdraw",args:[{type:"integer", value: 1000000}]}, payment: []}))

์Šคํฌ๋ฆฝํŠธ๊ฐ€ ์ž‘๋™ํ•˜๊ณ  ๋‘ ๋ฒˆ์งธ ์š”์ ์„ ์•Œ์•„๋ƒˆ์Šต๋‹ˆ๋‹ค!

4๋‹จ๊ณ„. ํˆฌํ‘œ๋ฅผ ํ†ตํ•ด DAO ์ƒ์„ฑ

๋ถˆํ–‰ํ•˜๊ฒŒ๋„ RIDE ์–ธ์–ด๋Š” ์•„์ง ์ปฌ๋ ‰์…˜(์‚ฌ์ „ ์‚ฌ์ „, ๋ฐ˜๋ณต์ž, ๋ฆฌ๋“€์„œ ๋“ฑ) ์ž‘์—… ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ํ”Œ๋žซ ์ปฌ๋ ‰์…˜์„ ์‚ฌ์šฉํ•˜๋Š” ๋ชจ๋“  ์ž‘์—…์˜ โ€‹โ€‹๊ฒฝ์šฐ ํ•ต์‹ฌ ๊ฐ€์น˜ ์šฐ๋ฆฌ๋Š” ํ‚ค์™€ ์•”ํ˜ธ ํ•ด๋…์— ๋”ฐ๋ผ ๋ฌธ์ž์—ด ์ž‘์—…์„ ์œ„ํ•œ ์‹œ์Šคํ…œ์„ ์„ค๊ณ„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋ฌธ์ž์—ด์€ ์—ฐ๊ฒฐํ•˜๊ธฐ๊ฐ€ ๋งค์šฐ ์‰ฝ์Šต๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์€ ์ธ๋ฑ์Šค๋กœ ๊ตฌ๋ถ„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
ํ…Œ์ŠคํŠธ ์˜ˆ์‹œ๋กœ ๋ฌธ์ž์—ด์„ ์ˆ˜์ง‘ํ•˜๊ณ  ๊ตฌ๋ฌธ ๋ถ„์„ํ•˜์—ฌ ์ด๊ฒƒ์ด ํŠธ๋žœ์žญ์…˜ ๊ฒฐ๊ณผ์— ์–ด๋–ค ์˜ํ–ฅ์„ ๋ฏธ์น˜๋Š”์ง€ ํ™•์ธํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.
์šฐ๋ฆฌ๋Š” ์ด๋Ÿฌํ•œ ์œ ํ˜•์˜ ๊ฑฐ๋ž˜์— ๋Œ€ํ•ด @verifier์—์„œ ์ด ๊ธฐํšŒ๊ฐ€ ์ฐจ๋‹จ๋˜์—ˆ๊ธฐ ๋•Œ๋ฌธ์— Alice๊ฐ€ ์ด์ฒด ๊ฑฐ๋ž˜์— ์„œ๋ช…ํ•  ์ˆ˜ ์—†๋‹ค๋Š” ์‚ฌ์‹ค์— ํ•ฉ์˜ํ–ˆ์Šต๋‹ˆ๋‹ค.

๋ฌธ์ž์—ด๋กœ ์—ฐ์Šตํ•œ ํ›„ ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

๋ผ์ด๋“œ ์ŠคํŠธ๋ง

๊ฑฐ๋ž˜๊ฐ€ ๋‹ค์‹œ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ๋ฌธ์ž์—ด ์ž‘์—… ๋ฐฉ๋ฒ•์„ ์•Œ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
RIDE ๋ฐ RIDE4DAPPS์—์„œ Waves ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์›๋‹ˆ๋‹ค. 2๋ถ€(DAO - ๋ถ„์‚ฐํ˜• ์ž์œจ ์กฐ์ง)

๏ฟผ
์ „์ฒด์ ์œผ๋กœ ์šฐ๋ฆฌ๋Š” ๋ณต์žกํ•œ ๋…ผ๋ฆฌ๋ฅผ ์ž‘์„ฑํ•˜๋Š” ๋ฐ ํ•„์š”ํ•œ ๋ชจ๋“  ๊ฒƒ์„ ๊ฐ–์ถ”๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. DAO ๋””์•ฑ.

๋ฐ์ดํ„ฐ ๊ฑฐ๋ž˜

๋ฐ์ดํ„ฐ ๊ฑฐ๋ž˜:
โ€œํ‚ค์˜ ์ตœ๋Œ€ ํฌ๊ธฐ๋Š” 100์ž์ด๋ฉฐ ํ‚ค์—๋Š” ๊ณต๋ฐฑ ๋ฐ ๊ธฐํƒ€ ์ธ์‡„ํ•  ์ˆ˜ ์—†๋Š” ๊ธฐํ˜ธ๋ฅผ ํฌํ•จํ•˜์—ฌ ์ž„์˜์˜ ์œ ๋‹ˆ์ฝ”๋“œ ์ฝ”๋“œ ํฌ์ธํŠธ๊ฐ€ ํฌํ•จ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด ๊ฐ’์€ 32,768๋ฐ”์ดํŠธ๋กœ ์ œํ•œ๋˜๋ฉฐ ๋ฐ์ดํ„ฐ ํŠธ๋žœ์žญ์…˜์— ๊ฐ€๋Šฅํ•œ ์ตœ๋Œ€ ํ•ญ๋ชฉ ์ˆ˜๋Š” 100๊ฐœ์ž…๋‹ˆ๋‹ค. ์ „์ฒด์ ์œผ๋กœ ๋ฐ์ดํ„ฐ ํŠธ๋žœ์žญ์…˜์˜ ์ตœ๋Œ€ ํฌ๊ธฐ๋Š” ์•ฝ 140kb์ž…๋‹ˆ๋‹ค. ์ฐธ๊ณ ๋กœ ์…ฐ์ต์Šคํ”ผ์–ด์˜ ํฌ๊ณก '๋กœ๋ฏธ์˜ค์™€ ์ค„๋ฆฌ์—ฃ'์˜ ๊ธธ์ด์™€ ๊ฑฐ์˜ ์ •ํ™•ํžˆ ๊ฐ™์Šต๋‹ˆ๋‹ค. '.โ€

์šฐ๋ฆฌ๋Š” ๋‹ค์Œ ์กฐ๊ฑด์œผ๋กœ DAO๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
์Šคํƒ€ํŠธ์—…์ด ์ „ํ™”ํ•ด์„œ ์ž๊ธˆ์„ ๋ฐ›๊ธฐ ์œ„ํ•ด์„œ๋Š” getFunds() ์ตœ์†Œ 2๋ช…์˜ ์ฐธ๊ฐ€์ž(DAO ํˆฌ์ž์ž)์˜ ์ง€์›์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์ฒ ์ˆ˜ ์— ํ‘œ์‹œ๋œ ์ด ๊ธˆ์•ก๋งŒํผ ์ •ํ™•ํ•˜๊ฒŒ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ํˆฌํ‘œ DAO ์†Œ์œ ์ž.

3๊ฐ€์ง€ ์œ ํ˜•์˜ ํ‚ค๋ฅผ ๋งŒ๋“ค๊ณ  2๊ฐœ์˜ ์ƒˆ๋กœ์šด ํ•จ์ˆ˜ vote ๋ฐ getFunds์—์„œ ์ž”์•ก ์ž‘์—…์„ ์œ„ํ•œ ๋กœ์ง์„ ์ถ”๊ฐ€ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.
xxโ€ฆxx_ia = ํˆฌ์ž์ž, ์‚ฌ์šฉ ๊ฐ€๋Šฅ ์ž”์•ก (ํˆฌํ‘œ, ์ž…๊ธˆ, ์ถœ๊ธˆ)
xxโ€ฆxx_sv = ์Šคํƒ€ํŠธ์—…, ํˆฌํ‘œ์ˆ˜ (ํˆฌํ‘œ, getFunds)
xxโ€ฆxx_sf = ์Šคํƒ€ํŠธ์—…, ํˆฌํ‘œ์ˆ˜ (ํˆฌํ‘œ, getFunds)
xxโ€ฆxx = ๊ณต๊ฐœ ์ฃผ์†Œ(35์ž)

Vote์—์„œ๋Š” ์—ฌ๋Ÿฌ ํ•„๋“œ๋ฅผ ํ•œ ๋ฒˆ์— ์—…๋ฐ์ดํŠธํ•ด์•ผ ํ–ˆ์Šต๋‹ˆ๋‹ค.

WriteSet([DataEntry(key1, value1), DataEntry(key2, value2)]),

WriteSet์„ ์‚ฌ์šฉํ•˜๋ฉด ํ•˜๋‚˜์˜ ๋ ˆ์ฝ”๋“œ์—์„œ ๋™์‹œ์— ์—ฌ๋Ÿฌ ๋ ˆ์ฝ”๋“œ๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ˜ธ์ถœ์Šคํฌ๋ฆฝํŠธ ์—…๋ฌด.

Bob๊ณผ Cooper๊ฐ€ ๋ณด์ถฉํ•œ ํ›„ DAO dApp์˜ ํ‚ค-๊ฐ’ ์ €์žฅ์†Œ์˜ ๋ชจ์Šต์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. ia-๋งค์žฅ:
RIDE ๋ฐ RIDE4DAPPS์—์„œ Waves ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์›๋‹ˆ๋‹ค. 2๋ถ€(DAO - ๋ถ„์‚ฐํ˜• ์ž์œจ ์กฐ์ง)

์ž…๊ธˆ ๊ธฐ๋Šฅ์ด ์•ฝ๊ฐ„ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค:
RIDE ๋ฐ RIDE4DAPPS์—์„œ Waves ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์›๋‹ˆ๋‹ค. 2๋ถ€(DAO - ๋ถ„์‚ฐํ˜• ์ž์œจ ์กฐ์ง)

์ด์ œ DAO ํ™œ๋™์—์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ์ˆœ๊ฐ„์ด ์™”์Šต๋‹ˆ๋‹ค. ํˆฌํ‘œ ํ”„๋กœ์ ํŠธ ์ž๊ธˆ ์กฐ๋‹ฌ์„ ์œ„ํ•ด.

Bob์€ Neli์˜ 500000๊ฐœ ์›จ์ด๋ธ”๋ฆฟ ํ”„๋กœ์ ํŠธ์— ํˆฌํ‘œํ–ˆ์Šต๋‹ˆ๋‹ค.

broadcast(invokeScript({dappAddress: address(env.accounts[1]), call:{function:"vote",args:[{type:"integer", value: 500000}, {type:"string", value: "3MrXEKJr9nDLNyVZ1d12Mq4jjeUYwxNjMsH"}]}, payment: []}))

RIDE ๋ฐ RIDE4DAPPS์—์„œ Waves ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์›๋‹ˆ๋‹ค. 2๋ถ€(DAO - ๋ถ„์‚ฐํ˜• ์ž์œจ ์กฐ์ง)

๋ฐ์ดํ„ฐ ์ €์žฅ์†Œ์—๋Š” Neli์˜ ์ฃผ์†Œ์— ํ•„์š”ํ•œ ๋ชจ๋“  ํ•ญ๋ชฉ์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.
RIDE ๋ฐ RIDE4DAPPS์—์„œ Waves ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์›๋‹ˆ๋‹ค. 2๋ถ€(DAO - ๋ถ„์‚ฐํ˜• ์ž์œจ ์กฐ์ง)
Cooper๋Š” Neli ํ”„๋กœ์ ํŠธ์—๋„ ํˆฌํ‘œํ–ˆ์Šต๋‹ˆ๋‹ค.
RIDE ๋ฐ RIDE4DAPPS์—์„œ Waves ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์›๋‹ˆ๋‹ค. 2๋ถ€(DAO - ๋ถ„์‚ฐํ˜• ์ž์œจ ์กฐ์ง)

ํ•จ์ˆ˜์ฝ”๋“œ๋ฅผ ์‚ดํŽด๋ณด์ž getFunds. Neli๋Š” DAO์—์„œ ์ž๊ธˆ์„ ์ธ์ถœํ•˜๋ ค๋ฉด ์ตœ์†Œ 2ํ‘œ๋ฅผ ๋ชจ์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค.
RIDE ๋ฐ RIDE4DAPPS์—์„œ Waves ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์›๋‹ˆ๋‹ค. 2๋ถ€(DAO - ๋ถ„์‚ฐํ˜• ์ž์œจ ์กฐ์ง)

Neli๋Š” ์ž์‹ ์—๊ฒŒ ๋งก๊ฒจ์ง„ ๊ธˆ์•ก์˜ ์ ˆ๋ฐ˜์„ ์ธ์ถœํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.

broadcast(invokeScript({dappAddress: address(env.accounts[1]), call:{function:"getFunds",args:[{type:"integer", value: 500000}]}, payment: []}))

RIDE ๋ฐ RIDE4DAPPS์—์„œ Waves ์Šค๋งˆํŠธ ๊ณ„์•ฝ์„ ์ž‘์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์›๋‹ˆ๋‹ค. 2๋ถ€(DAO - ๋ถ„์‚ฐํ˜• ์ž์œจ ์กฐ์ง)

๊ทธ๋…€๋Š” ์„ฑ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰, DAO๊ฐ€ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค!

์–ธ์–ด๋กœ DAO๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๊ณผ์ •์„ ์‚ดํŽด๋ณด์•˜์Šต๋‹ˆ๋‹ค. RIDE4DAPPS.
๋‹ค์Œ ๋ถ€๋ถ„์—์„œ๋Š” ์ฝ”๋“œ ๋ฆฌํŒฉํ† ๋ง๊ณผ ์‚ฌ๋ก€ ํ…Œ์ŠคํŠธ๋ฅผ ์ž์„ธํžˆ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

์ฝ”๋“œ์˜ ์ „์ฒด ๋ฒ„์ „ ์›จ์ด๋ธŒ ๋ผ์ด๋“œ IDE:

# In this example multiple accounts can deposit their funds to DAO and safely take them back, no one can interfere with this.
# DAO participants can also vote for particular addresses and let them withdraw invested funds then quorum has reached.
# An inner state is maintained as mapping `address=>waves`.
# https://medium.com/waves-lab/waves-announces-funding-for-ride-for-dapps-developers-f724095fdbe1

# You can try this contract by following commands in the IDE (ide.wavesplatform.com)
# Run commands as listed below
# From account #0:
#      deploy()
# From account #1: deposit funds
#      broadcast(invokeScript({dappAddress: address(env.accounts[1]), call:{function:"deposit",args:[]}, payment: [{amount: 100000000, asset:null }]}))
# From account #2: deposit funds
#      broadcast(invokeScript({dappAddress: address(env.accounts[1]), call:{function:"deposit",args:[]}, payment: [{amount: 100000000, asset:null }]}))
# From account #1: vote for startup
#      broadcast(invokeScript({dappAddress: address(env.accounts[1]), call:{function:"vote",args:[{type:"integer", value: 500000}, {type:"string", value: "3MrXEKJr9nDLNyVZ1d12Mq4jjeUYwxNjMsH"}]}, payment: []}))
# From account #2: vote for startup
#      broadcast(invokeScript({dappAddress: address(env.accounts[1]), call:{function:"vote",args:[{type:"integer", value: 500000}, {type:"string", value: "3MrXEKJr9nDLNyVZ1d12Mq4jjeUYwxNjMsH"}]}, payment: []}))
# From account #3: get invested funds
#      broadcast(invokeScript({dappAddress: address(env.accounts[1]), call:{function:"getFunds",args:[{type:"integer", value: 500000}]}, payment: []}))

{-# STDLIB_VERSION 3 #-}
{-# CONTENT_TYPE DAPP #-}
{-# SCRIPT_TYPE ACCOUNT #-}

@Callable(i)
func deposit() = {
   let pmt = extract(i.payment)
   if (isDefined(pmt.assetId)) then throw("can hodl waves only at the moment")
   else {
        let currentKey = toBase58String(i.caller.bytes)
        let xxxInvestorBalance = currentKey + "_" + "ib"
        let currentAmount = match getInteger(this, xxxInvestorBalance) {
            case a:Int => a
            case _ => 0
        }
        let newAmount = currentAmount + pmt.amount
        WriteSet([DataEntry(xxxInvestorBalance, newAmount)])
   }
}
@Callable(i)
func withdraw(amount: Int) = {
        let currentKey = toBase58String(i.caller.bytes)
        let xxxInvestorBalance = currentKey + "_" + "ib"
        let currentAmount = match getInteger(this, xxxInvestorBalance) {
            case a:Int => a
            case _ => 0
        }
        let newAmount = currentAmount - amount
     if (amount < 0)
            then throw("Can't withdraw negative amount")
    else if (newAmount < 0)
            then throw("Not enough balance")
            else ScriptResult(
                    WriteSet([DataEntry(xxxInvestorBalance, newAmount)]),
                    TransferSet([ScriptTransfer(i.caller, amount, unit)])
                )
    }
@Callable(i)
func getFunds(amount: Int) = {
        let quorum = 2
        let currentKey = toBase58String(i.caller.bytes)
        let xxxStartupFund = currentKey + "_" + "sf"
        let xxxStartupVotes = currentKey + "_" + "sv"
        let currentAmount = match getInteger(this, xxxStartupFund) {
            case a:Int => a
            case _ => 0
        }
        let totalVotes = match getInteger(this, xxxStartupVotes) {
            case a:Int => a
            case _ => 0
        }
        let newAmount = currentAmount - amount
    if (amount < 0)
            then throw("Can't withdraw negative amount")
    else if (newAmount < 0)
            then throw("Not enough balance")
    else if (totalVotes < quorum)
            then throw("Not enough votes. At least 2 votes required!")
    else ScriptResult(
                    WriteSet([
                        DataEntry(xxxStartupFund, newAmount)
                        ]),
                    TransferSet([ScriptTransfer(i.caller, amount, unit)])
                )
    }
@Callable(i)
func vote(amount: Int, address: String) = {
        let currentKey = toBase58String(i.caller.bytes)
        let xxxInvestorBalance = currentKey + "_" + "ib"
        let xxxStartupFund = address + "_" + "sf"
        let xxxStartupVotes = address + "_" + "sv"
        let currentAmount = match getInteger(this, xxxInvestorBalance) {
            case a:Int => a
            case _ => 0
        }
        let currentVotes = match getInteger(this, xxxStartupVotes) {
            case a:Int => a
            case _ => 0
        }
        let currentFund = match getInteger(this, xxxStartupFund) {
            case a:Int => a
            case _ => 0
        }
    if (amount <= 0)
            then throw("Can't withdraw negative amount")
    else if (amount > currentAmount)
            then throw("Not enough balance")
    else ScriptResult(
                    WriteSet([
                        DataEntry(xxxInvestorBalance, currentAmount - amount),
                        DataEntry(xxxStartupVotes, currentVotes + 1),
                        DataEntry(xxxStartupFund, currentFund + amount)
                        ]),
                    TransferSet([ScriptTransfer(i.caller, amount, unit)])
            )
    }
@Verifier(tx)
func verify() = {
    match tx {
        case t: TransferTransaction =>false
        case _ => true
    }
}

์ฒซ ๋ฒˆ์งธ ๋ถ€๋ถ„
GitHub์˜ ์ฝ”๋“œ
์›จ์ด๋ธŒ ๋ผ์ด๋“œ IDE
๋ณด์กฐ๊ธˆ ํ”„๋กœ๊ทธ๋žจ ๋ฐœํ‘œ

์ถœ์ฒ˜ : habr.com

์ฝ”๋ฉ˜ํŠธ๋ฅผ ์ถ”๊ฐ€