Skip to content

Commit ec86e5a

Browse files
authored
Fix moved signer value in "Getting started" example (#166)
Currently example in "_Getting started_" doesn't build as `signer` value is moved when `provider` is initialized before address is got from the signer. This fixes this by moving `from_address` below signer initialization so it's got before passing signer to the provider.
1 parent c8a8ddc commit ec86e5a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

vocs/docs/pages/introduction/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ sol! { // [!code focus]
106106

107107
#[tokio::main]
108108
async fn main() -> Result<(), Box<dyn Error>> {
109-
// Initialize a signer with a private key
109+
// Initialize a signer with a private key and get address from it
110110
let signer: PrivateKeySigner =
111111
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80".parse()?;
112+
let from_address = signer.address();
112113

113114
// Instantiate a provider with the signer
114115
let provider = ProviderBuilder::new() // [!code focus]
@@ -120,7 +121,6 @@ async fn main() -> Result<(), Box<dyn Error>> {
120121
let weth = WETH9::new(weth_address, provider.clone()); // [!code focus]
121122

122123
// Read initial balance
123-
let from_address = signer.address();
124124
let initial_balance = weth.balanceOf(from_address).call().await?; // [!code focus]
125125
println!("Initial WETH balance: {} WETH", format_ether(initial_balance));
126126

0 commit comments

Comments
 (0)