-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add
sign_deploy_contract
example
- Loading branch information
dj8yf0μl
committed
Jan 29, 2024
1 parent
96d5eb2
commit 740b45c
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use near_ledger::NEARLedgerError; | ||
use near_primitives::transaction::DeployContractAction; | ||
use near_primitives_core::hash::CryptoHash; | ||
|
||
#[path = "../common/lib.rs"] | ||
mod common; | ||
|
||
fn tx(ledger_pub_key: ed25519_dalek::PublicKey) -> near_primitives::transaction::Transaction { | ||
let mut tx = common::tx_template(ledger_pub_key); | ||
|
||
let code = core::iter::repeat(42u8).take(300).collect::<Vec<_>>(); | ||
|
||
let code_hash = CryptoHash::hash_bytes(&code); | ||
println!("Contract code hash: {:?}", code_hash); | ||
tx.actions = vec![near_primitives::transaction::Action::DeployContract( | ||
DeployContractAction { code }, | ||
)]; | ||
tx | ||
} | ||
|
||
fn main() -> Result<(), NEARLedgerError> { | ||
common::get_key_sign_and_verify_flow(tx) | ||
} |