Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
Método de pago agregar o/agregar acumular adjunto_depósito al mapa

Hola, tengo un contrato de óxido con React frontend y tengo un método de cambio llamado donación . Me gustaría agregar un depósito adjunto y quien sea la cuenta del remitente a mis seguidores de HashMap. Si esta es la primera donación de esa persona, agréguela a ella y su donación; de lo contrario, agregue este depósito a lo que ya ha donado. Actualmente solo puedo agregarlos con insert, lo que no ayuda, ya que anula cualquier valor existente. Quiero acumular donaciones de personas. Lo que tengo es lo siguiente:

 #[payable] pub fn donation( &mut self, token_id: TokenId, ) { assert_at_least_one_yocto(); //measure the initial storage being used on the contract let initial_storage_usage = env::storage_usage(); let supporter_id = env::predecessor_account_id(); //get the token object form the token ID let mut token = self.tokens_by_id.get(&token_id).expect("No token"); //insert supporter and amount token.supporters.insert(supporter_id, env::attached_deposit()); //insert the metadata back into the token by ID self.tokens_by_id.insert(&token_id, &token); //calculate the required storage which was the used - initial let required_storage_in_bytes = env::storage_usage() - initial_storage_usage; //refund any excess storage if the user attached too much. Panic if they didn't attach enough to cover the required. refund_deposit(required_storage_in_bytes); }

Yo uso lo siguiente en la interfaz:

 await contract.donation({token_id: "token-2", supporter_id: "sp02.testnet"}, "300000000000000", "3000000000000000000000000")

¡Cualquier ayuda sería muy apreciada!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!